summary refs log tree commit diff
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2021-07-19 14:49:57 -0400
committerLoren Burkholder <computersemiexpert@outlook.com>2021-07-20 21:48:03 -0400
commit21eb312f69111b8141e2ac9da5bb3871287045bd (patch)
treee35915f6da401d9d0add75e92a2272256c500143
parentConsolidate connections (diff)
downloadnheko-21eb312f69111b8141e2ac9da5bb3871287045bd.tar.xz
Only run spinner while loading members
-rw-r--r--resources/qml/RoomMembers.qml2
-rw-r--r--src/MemberList.cpp6
-rw-r--r--src/MemberList.h4
3 files changed, 11 insertions, 1 deletions
diff --git a/resources/qml/RoomMembers.qml b/resources/qml/RoomMembers.qml
index 57353132..b190be07 100644
--- a/resources/qml/RoomMembers.qml
+++ b/resources/qml/RoomMembers.qml
@@ -116,7 +116,7 @@ ApplicationWindow {
                 }
 
                 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
                     height: visible ? undefined : 0
                     anchors.centerIn: parent
diff --git a/src/MemberList.cpp b/src/MemberList.cpp
index 04377a0f..415e3b57 100644
--- a/src/MemberList.cpp
+++ b/src/MemberList.cpp
@@ -98,8 +98,14 @@ MemberList::canFetchMore(const QModelIndex &) const
 void
 MemberList::fetchMore(const QModelIndex &)
 {
+        loadingMoreMembers_ = true;
+        emit loadingMoreMembersChanged();
+
         auto members = cache::getMembers(room_id_.toStdString(), rowCount());
         addUsers(members);
         numUsersLoaded_ += members.size();
         emit numUsersLoadedChanged();
+
+        loadingMoreMembers_ = false;
+        emit loadingMoreMembersChanged();
 }
diff --git a/src/MemberList.h b/src/MemberList.h
index cc3b75f7..070666a2 100644
--- a/src/MemberList.h
+++ b/src/MemberList.h
@@ -16,6 +16,7 @@ class MemberList : public QAbstractListModel
         Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
         Q_PROPERTY(QString roomId READ roomId NOTIFY roomIdChanged)
         Q_PROPERTY(int numUsersLoaded READ numUsersLoaded NOTIFY numUsersLoadedChanged)
+        Q_PROPERTY(bool loadingMoreMembers READ loadingMoreMembers NOTIFY loadingMoreMembersChanged)
 
 public:
         enum Roles
@@ -39,6 +40,7 @@ public:
         QString avatarUrl() const { return QString::fromStdString(info_.avatar_url); }
         QString roomId() const { return room_id_; }
         int numUsersLoaded() const { return numUsersLoaded_; }
+        bool loadingMoreMembers() const { return loadingMoreMembers_; }
 
 signals:
         void roomNameChanged();
@@ -46,6 +48,7 @@ signals:
         void avatarUrlChanged();
         void roomIdChanged();
         void numUsersLoadedChanged();
+        void loadingMoreMembersChanged();
 
 public slots:
         void addUsers(const std::vector<RoomMember> &users);
@@ -59,4 +62,5 @@ private:
         QString room_id_;
         RoomInfo info_;
         int numUsersLoaded_{0};
+        bool loadingMoreMembers_{false};
 };