Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Jan 15, 2025
1 parent 4f38e79 commit 6c91b8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/sliding-sync-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

0 comments on commit 6c91b8d

Please sign in to comment.