mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Only run spinner while loading members
This commit is contained in:
parent
a7bdbc2af2
commit
21eb312f69
3 changed files with 11 additions and 1 deletions
|
@ -116,7 +116,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: Spinner {
|
footer: Spinner {
|
||||||
visible: members.numUsersLoaded < members.memberCount
|
visible: members.numUsersLoaded < members.memberCount && members.loadingMoreMembers
|
||||||
// use the default height if it's visible, otherwise no height at all
|
// use the default height if it's visible, otherwise no height at all
|
||||||
height: visible ? undefined : 0
|
height: visible ? undefined : 0
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
|
@ -98,8 +98,14 @@ MemberList::canFetchMore(const QModelIndex &) const
|
||||||
void
|
void
|
||||||
MemberList::fetchMore(const QModelIndex &)
|
MemberList::fetchMore(const QModelIndex &)
|
||||||
{
|
{
|
||||||
|
loadingMoreMembers_ = true;
|
||||||
|
emit loadingMoreMembersChanged();
|
||||||
|
|
||||||
auto members = cache::getMembers(room_id_.toStdString(), rowCount());
|
auto members = cache::getMembers(room_id_.toStdString(), rowCount());
|
||||||
addUsers(members);
|
addUsers(members);
|
||||||
numUsersLoaded_ += members.size();
|
numUsersLoaded_ += members.size();
|
||||||
emit numUsersLoadedChanged();
|
emit numUsersLoadedChanged();
|
||||||
|
|
||||||
|
loadingMoreMembers_ = false;
|
||||||
|
emit loadingMoreMembersChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class MemberList : public QAbstractListModel
|
||||||
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
|
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
|
||||||
Q_PROPERTY(QString roomId READ roomId NOTIFY roomIdChanged)
|
Q_PROPERTY(QString roomId READ roomId NOTIFY roomIdChanged)
|
||||||
Q_PROPERTY(int numUsersLoaded READ numUsersLoaded NOTIFY numUsersLoadedChanged)
|
Q_PROPERTY(int numUsersLoaded READ numUsersLoaded NOTIFY numUsersLoadedChanged)
|
||||||
|
Q_PROPERTY(bool loadingMoreMembers READ loadingMoreMembers NOTIFY loadingMoreMembersChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles
|
enum Roles
|
||||||
|
@ -39,6 +40,7 @@ public:
|
||||||
QString avatarUrl() const { return QString::fromStdString(info_.avatar_url); }
|
QString avatarUrl() const { return QString::fromStdString(info_.avatar_url); }
|
||||||
QString roomId() const { return room_id_; }
|
QString roomId() const { return room_id_; }
|
||||||
int numUsersLoaded() const { return numUsersLoaded_; }
|
int numUsersLoaded() const { return numUsersLoaded_; }
|
||||||
|
bool loadingMoreMembers() const { return loadingMoreMembers_; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void roomNameChanged();
|
void roomNameChanged();
|
||||||
|
@ -46,6 +48,7 @@ signals:
|
||||||
void avatarUrlChanged();
|
void avatarUrlChanged();
|
||||||
void roomIdChanged();
|
void roomIdChanged();
|
||||||
void numUsersLoadedChanged();
|
void numUsersLoadedChanged();
|
||||||
|
void loadingMoreMembersChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addUsers(const std::vector<RoomMember> &users);
|
void addUsers(const std::vector<RoomMember> &users);
|
||||||
|
@ -59,4 +62,5 @@ private:
|
||||||
QString room_id_;
|
QString room_id_;
|
||||||
RoomInfo info_;
|
RoomInfo info_;
|
||||||
int numUsersLoaded_{0};
|
int numUsersLoaded_{0};
|
||||||
|
bool loadingMoreMembers_{false};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue