Support adding 3 PIDs

Implements part of network/neochat#565

Note the phone number stuff is untested as neither kde.org or matrix.org have them switched on.
This commit is contained in:
James Graham
2024-05-12 17:02:09 +00:00
parent 0dfeec6cae
commit 1a2272249d
16 changed files with 578 additions and 16 deletions

View File

@@ -10,15 +10,7 @@ ThreePIdModel::ThreePIdModel(NeoChatConnection *connection)
{
Q_ASSERT(connection);
connect(connection, &NeoChatConnection::stateChanged, this, [this]() {
const auto connection = dynamic_cast<NeoChatConnection *>(this->parent());
if (connection != nullptr && connection->isLoggedIn()) {
const auto threePIdJob = connection->callApi<Quotient::GetAccount3PIDsJob>();
connect(threePIdJob, &Quotient::BaseJob::success, this, [this, threePIdJob]() {
beginResetModel();
m_threePIds = threePIdJob->threepids();
endResetModel();
});
}
refreshModel();
});
}
@@ -56,4 +48,17 @@ QHash<int, QByteArray> ThreePIdModel::roleNames() const
};
}
void ThreePIdModel::refreshModel()
{
const auto connection = dynamic_cast<NeoChatConnection *>(this->parent());
if (connection != nullptr && connection->isLoggedIn()) {
const auto threePIdJob = connection->callApi<Quotient::GetAccount3PIDsJob>();
connect(threePIdJob, &Quotient::BaseJob::success, this, [this, threePIdJob]() {
beginResetModel();
m_threePIds = threePIdJob->threepids();
endResetModel();
});
}
}
#include "moc_threepidmodel.cpp"