aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp6
-rw-r--r--lib/connection.h31
2 files changed, 30 insertions, 7 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 572ac76b..dae7b663 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -82,6 +82,7 @@ class Connection::Private
// Leave state of the same room.
QHash<QPair<QString, bool>, Room*> roomMap;
QVector<QString> roomIdsToForget;
+ QVector<Room*> firstTimeRooms;
QMap<QString, User*> userMap;
DirectChatsMap directChats;
QHash<QString, AccountDataMap> accountData;
@@ -308,7 +309,11 @@ void Connection::onSyncSuccess(SyncData &&data) {
<< "state - suspiciously fast turnaround";
}
if ( auto* r = provideRoom(roomData.roomId, roomData.joinState) )
+ {
r->updateData(std::move(roomData));
+ if (d->firstTimeRooms.removeOne(r))
+ emit loadedRoomState(r);
+ }
QCoreApplication::processEvents();
}
for (auto&& accountEvent: data.takeAccountData())
@@ -804,6 +809,7 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState)
return nullptr;
}
d->roomMap.insert(roomKey, room);
+ d->firstTimeRooms.push_back(room);
emit newRoom(room);
}
if (joinState == JoinState::Invite)
diff --git a/lib/connection.h b/lib/connection.h
index 197e4785..2c4c622d 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -435,18 +435,22 @@ namespace QMatrixClient
/** A new room object has been created */
void newRoom(Room* room);
- /** Invitation to a room received
+ /** A room invitation is seen for the first time
*
- * If the same room is in Left state, it's passed in prev.
+ * If the same room is in Left state, it's passed in prev. Beware
+ * that initial sync will trigger this signal for all rooms in
+ * Invite state.
*/
void invitedRoom(Room* room, Room* prev);
- /** A room has just been joined
+ /** A joined room is seen for the first time
*
* It's not the same as receiving a room in "join" section of sync
- * response (rooms will be there even after joining). If this room
- * was in Invite state before, the respective object is passed in
- * prev (and it will be deleted shortly afterwards).
+ * response (rooms will be there even after joining); it's also
+ * not (exactly) the same as actual joining action of a user (all
+ * rooms coming in initial sync will trigger this signal too). If
+ * this room was in Invite state before, the respective object is
+ * passed in prev (and it will be deleted shortly afterwards).
*/
void joinedRoom(Room* room, Room* prev);
@@ -454,7 +458,10 @@ namespace QMatrixClient
*
* If this room has been in Invite state (as in case of rejecting
* an invitation), the respective object will be passed in prev
- * (and will be deleted shortly afterwards).
+ * (and will be deleted shortly afterwards). Note that, similar
+ * to invitedRoom and joinedRoom, this signal is triggered for all
+ * Left rooms upon initial sync (not only those that were left
+ * right before the sync).
*/
void leftRoom(Room* room, Room* prev);
@@ -472,6 +479,16 @@ namespace QMatrixClient
*/
void createdRoom(Room* room);
+ /** The first sync for the room has been completed
+ *
+ * This signal is emitted after the room has been synced the first
+ * time. This is the right signal to connect to if you need to
+ * access the room state (name, aliases, members); state transition
+ * signals (newRoom, joinedRoom etc.) come earlier, when the room
+ * has just been created.
+ */
+ void loadedRoomState(Room* room);
+
/** Account data (except direct chats) have changed */
void accountDataChanged(QString type);