From 6c91b8df64624f1f118d3f61bd0f686602740394 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 15 Jan 2025 11:04:21 +0000 Subject: [PATCH] Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/sliding-sync-sdk.ts | 5 ++++- src/sync.ts | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sliding-sync-sdk.ts b/src/sliding-sync-sdk.ts index 9b15dbb658..5199935198 100644 --- a/src/sliding-sync-sdk.ts +++ b/src/sliding-sync-sdk.ts @@ -390,7 +390,6 @@ export class SlidingSyncSdk { } room = _createAndReEmitRoom(this.client, roomId, this.opts); this.client.store.storeRoom(room); - this.client.emit(ClientEvent.Room, room); } await this.processRoomData(this.client, room!, roomData); } @@ -646,6 +645,7 @@ export class SlidingSyncSdk { await this.injectRoomEvents(room, inviteStateEvents); if (roomData.initial) { room.recalculate(); + this.client.emit(ClientEvent.Room, room); } inviteStateEvents.forEach((e) => { this.client.emit(ClientEvent.Event, e); @@ -723,6 +723,9 @@ export class SlidingSyncSdk { room.updateMyMembership(KnownMembership.Join); room.recalculate(); + if (roomData.initial) { + this.client.emit(ClientEvent.Room, room); + } // check if any timeline events should bing and add them to the notifEvents array: // we'll purge this once we've fully processed the sync response diff --git a/src/sync.ts b/src/sync.ts index fb23de18d7..34aea9a6e9 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -1468,6 +1468,9 @@ export class SyncApi { // we deliberately don't add accountData to the timeline room.addAccountData(accountDataEvents); room.recalculate(); + if (joinObj.isBrandNewRoom) { + client.emit(ClientEvent.Room, room); + } this.processEventsForNotifs(room, timelineEvents); @@ -1519,8 +1522,13 @@ export class SyncApi { await this.injectRoomEvents(room, stateEvents, undefined); - // Update room state for knock->leave->knock cycles - room.recalculate(); + if (knockObj.isBrandNewRoom) { + room.recalculate(); + client.emit(ClientEvent.Room, room); + } else { + // Update room state for knock->leave->knock cycles + room.recalculate(); + } stateEvents.forEach(function (e) { client.emit(ClientEvent.Event, e); }); @@ -1675,7 +1683,6 @@ export class SyncApi { if (!room) { room = this.createRoom(roomId); client.store.storeRoom(room); - client.emit(ClientEvent.Room, room); isBrandNewRoom = true; } return {