From 9b3e437f3268e251f1950000b210cf849d49c24e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 9 Dec 2018 20:04:45 +0900 Subject: [PATCH] Room: defer memberListChanged(); track room summary changes This concludes beta-version of lazy-loading support in libQMatrixClient (#253). --- lib/room.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index ca5495ea6..84072d3ef 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -282,9 +282,6 @@ Room::Room(Connection* connection, QString id, JoinState initialJoinState) // See "Accessing the Public Class" section in // https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl-%E2%80%94-reloaded/ d->q = this; - connect(this, &Room::userAdded, this, &Room::memberListChanged); - connect(this, &Room::userRemoved, this, &Room::memberListChanged); - connect(this, &Room::memberRenamed, this, &Room::memberListChanged); qCDebug(MAIN) << "New" << toCString(initialJoinState) << "Room:" << id; } @@ -1018,12 +1015,9 @@ Room::Changes Room::Private::setSummary(RoomSummary&& newSummary) { if (!summary.merge(newSummary)) return Change::NoChange; - summary = move(newSummary); - qCDebug(MAIN).nospace() - << "Updated room summary for" << q->objectName() - << ": joined " << summary.joinedMemberCount - << ", invited " << summary.invitedMemberCount - << ", heroes: " << summary.heroes.value().join(','); + qCDebug(MAIN).nospace().noquote() + << "Updated room summary for " << q->objectName() << ": " << summary; + emit q->memberListChanged(); return Change::SummaryChange; } @@ -1194,7 +1188,10 @@ void Room::updateData(SyncRoomData&& data, bool fromCache) if (roomChanges&NameChange) emit namesChanged(this); - d->setSummary(move(data.summary)); + if (roomChanges&MembersChange) + emit memberListChanged(); + + roomChanges |= d->setSummary(move(data.summary)); d->updateDisplayname(); for( auto&& ephemeralEvent: data.ephemeral )