Improve UserListModel performance and other preparations
In a future patch I want to add support for viewing banned/invited users, and it's also been mentioned that UserListModel is quite slow too. The biggest cost is sorting the member list (power level and alphabetically) and this happened in a few different ways: * When the member list updated * The user switches rooms * Misc events such as the palette changing But this was pretty inefficient, because internally Quotient::Room keeps a list of members, and we kept re-sorting that same list. Our connections were also too broad and despite having signals for members joining and leaving we just reloaded the entire list anyway. So my new solution is to keep the list persistently sorted in NeoChatRoom, and reload that in UserListModel. This model also keeps track of *all* members - including ones that left - which will be used for the aforementioned feature. So UserFilterModel now filters out only the joined members, and that will be configurable in the future. I also added two new roles to UserListModel for membership and color respectively (which makes some dead code useful again) and fixed us overwriting the built-in Qt roles accidentally.
This commit is contained in:
@@ -671,6 +671,11 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void markAllChildrenMessagesAsRead();
|
||||
|
||||
/**
|
||||
* @return List of members in this room, sorted by power level and then by name.
|
||||
*/
|
||||
QList<QString> sortedMemberIds() const;
|
||||
|
||||
private:
|
||||
bool m_visible = false;
|
||||
|
||||
@@ -707,6 +712,7 @@ private:
|
||||
void loadPinnedMessage();
|
||||
|
||||
QString m_lastUnreadHighlightId;
|
||||
QList<QString> m_sortedMemberIds;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updatePushNotificationState(QString type);
|
||||
@@ -715,6 +721,10 @@ private Q_SLOTS:
|
||||
|
||||
void invalidateLastUnreadHighlightId(const QString &fromEventId, const QString &toEventId);
|
||||
|
||||
void refreshAllMembers();
|
||||
|
||||
void insertMemberSorted(Quotient::RoomMember member);
|
||||
|
||||
Q_SIGNALS:
|
||||
void cachedInputChanged();
|
||||
void busyChanged();
|
||||
|
||||
Reference in New Issue
Block a user