Skip to content

Commit

Permalink
Room: defer memberListChanged(); track room summary changes
Browse files Browse the repository at this point in the history
This concludes beta-version of lazy-loading support in libQMatrixClient (#253).
  • Loading branch information
KitsuneRal committed Dec 9, 2018
1 parent 9225eae commit 9b3e437
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 9b3e437

Please sign in to comment.