mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Merge pull request #184 from shocklateboy92/features/backlog-progress
Add visual indication that data is being fetched
This commit is contained in:
commit
38417a374d
3 changed files with 33 additions and 8 deletions
|
@ -255,6 +255,13 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer: BusyIndicator {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
running: chat.model && chat.model.paginationInProgress
|
||||||
|
height: 50
|
||||||
|
width: 50
|
||||||
|
z: 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
@ -429,15 +429,26 @@ TimelineModel::canFetchMore(const QModelIndex &) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineModel::setPaginationInProgress(const bool paginationInProgress)
|
||||||
|
{
|
||||||
|
if (m_paginationInProgress == paginationInProgress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_paginationInProgress = paginationInProgress;
|
||||||
|
emit paginationInProgressChanged(m_paginationInProgress);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineModel::fetchMore(const QModelIndex &)
|
TimelineModel::fetchMore(const QModelIndex &)
|
||||||
{
|
{
|
||||||
if (paginationInProgress) {
|
if (m_paginationInProgress) {
|
||||||
nhlog::ui()->warn("Already loading older messages");
|
nhlog::ui()->warn("Already loading older messages");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
paginationInProgress = true;
|
setPaginationInProgress(true);
|
||||||
mtx::http::MessagesOpts opts;
|
mtx::http::MessagesOpts opts;
|
||||||
opts.room_id = room_id_.toStdString();
|
opts.room_id = room_id_.toStdString();
|
||||||
opts.from = prev_batch_token_.toStdString();
|
opts.from = prev_batch_token_.toStdString();
|
||||||
|
@ -452,12 +463,13 @@ TimelineModel::fetchMore(const QModelIndex &)
|
||||||
mtx::errors::to_string(err->matrix_error.errcode),
|
mtx::errors::to_string(err->matrix_error.errcode),
|
||||||
err->matrix_error.error,
|
err->matrix_error.error,
|
||||||
err->parse_error);
|
err->parse_error);
|
||||||
paginationInProgress = false;
|
emit oldMessagesRetrieved(std::move(res));
|
||||||
|
setPaginationInProgress(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit oldMessagesRetrieved(std::move(res));
|
emit oldMessagesRetrieved(std::move(res));
|
||||||
paginationInProgress = false;
|
setPaginationInProgress(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ class TimelineModel : public QAbstractListModel
|
||||||
Q_PROPERTY(std::vector<QString> typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY
|
Q_PROPERTY(std::vector<QString> typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY
|
||||||
typingUsersChanged)
|
typingUsersChanged)
|
||||||
Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply)
|
Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply)
|
||||||
|
Q_PROPERTY(
|
||||||
|
bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TimelineModel(TimelineViewManager *manager,
|
explicit TimelineModel(TimelineViewManager *manager,
|
||||||
|
@ -208,6 +210,7 @@ public slots:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<QString> typingUsers() const { return typingUsers_; }
|
std::vector<QString> typingUsers() const { return typingUsers_; }
|
||||||
|
bool paginationInProgress() const { return m_paginationInProgress; }
|
||||||
|
|
||||||
QString reply() const { return reply_; }
|
QString reply() const { return reply_; }
|
||||||
void setReply(QString newReply)
|
void setReply(QString newReply)
|
||||||
|
@ -246,6 +249,7 @@ signals:
|
||||||
void eventFetched(QString requestingEvent, mtx::events::collections::TimelineEvents event);
|
void eventFetched(QString requestingEvent, mtx::events::collections::TimelineEvents event);
|
||||||
void typingUsersChanged(std::vector<QString> users);
|
void typingUsersChanged(std::vector<QString> users);
|
||||||
void replyChanged(QString reply);
|
void replyChanged(QString reply);
|
||||||
|
void paginationInProgressChanged(const bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DecryptionResult decryptEvent(
|
DecryptionResult decryptEvent(
|
||||||
|
@ -261,6 +265,8 @@ private:
|
||||||
mtx::http::RequestErr err);
|
mtx::http::RequestErr err);
|
||||||
void readEvent(const std::string &id);
|
void readEvent(const std::string &id);
|
||||||
|
|
||||||
|
void setPaginationInProgress(const bool paginationInProgress);
|
||||||
|
|
||||||
QHash<QString, mtx::events::collections::TimelineEvents> events;
|
QHash<QString, mtx::events::collections::TimelineEvents> events;
|
||||||
QSet<QString> read;
|
QSet<QString> read;
|
||||||
QList<QString> pending;
|
QList<QString> pending;
|
||||||
|
@ -270,8 +276,8 @@ private:
|
||||||
QString prev_batch_token_;
|
QString prev_batch_token_;
|
||||||
|
|
||||||
bool isInitialSync = true;
|
bool isInitialSync = true;
|
||||||
bool paginationInProgress = false;
|
|
||||||
bool decryptDescription = true;
|
bool decryptDescription = true;
|
||||||
|
bool m_paginationInProgress = false;
|
||||||
|
|
||||||
QString currentId;
|
QString currentId;
|
||||||
QString reply_;
|
QString reply_;
|
||||||
|
|
Loading…
Reference in a new issue