Make the explore page search loading process more obvious

Adds progress bars, lots of them! Now it's easier to tell if NeoChat is
trying it's best to load the public room list.
This commit is contained in:
Joshua Goins
2023-08-17 17:37:24 -04:00
parent e53d63ad8b
commit 0a1c489401
3 changed files with 41 additions and 1 deletions

View File

@@ -41,6 +41,7 @@ void PublicRoomListModel::setConnection(Connection *conn)
if (job) {
job->abandon();
job = nullptr;
Q_EMIT loadingChanged();
}
if (m_connection) {
@@ -70,12 +71,14 @@ void PublicRoomListModel::setServer(const QString &value)
nextBatch = "";
attempted = false;
rooms.clear();
Q_EMIT loadingChanged();
endResetModel();
if (job) {
job->abandon();
job = nullptr;
Q_EMIT loadingChanged();
}
if (m_connection) {
@@ -110,6 +113,7 @@ void PublicRoomListModel::setKeyword(const QString &value)
if (job) {
job->abandon();
job = nullptr;
Q_EMIT loadingChanged();
}
if (m_connection) {
@@ -133,6 +137,7 @@ void PublicRoomListModel::next(int count)
}
job = m_connection->callApi<QueryPublicRoomsJob>(m_server, count, nextBatch, QueryPublicRoomsJob::Filter{m_keyword, {}});
Q_EMIT loadingChanged();
connect(job, &BaseJob::finished, this, [this] {
attempted = true;
@@ -150,6 +155,7 @@ void PublicRoomListModel::next(int count)
}
this->job = nullptr;
Q_EMIT loadingChanged();
});
}
@@ -253,4 +259,9 @@ bool PublicRoomListModel::hasMore() const
return !(attempted && nextBatch.isEmpty());
}
bool PublicRoomListModel::loading() const
{
return (job != nullptr) || isJobPending(job);
}
#include "moc_publicroomlistmodel.cpp"