diff --git a/src/client.ts b/src/client.ts index 5e3b4e1e939..8bc1a62a92b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -799,7 +799,9 @@ type RoomEvents = RoomEvent.Name type RoomStateEvents = RoomStateEvent.Events | RoomStateEvent.Members - | RoomStateEvent.NewMember; + | RoomStateEvent.NewMember + | RoomStateEvent.Update + ; type CryptoEvents = CryptoEvent.KeySignatureUploadFailure | CryptoEvent.KeyBackupStatus diff --git a/src/models/room-state.ts b/src/models/room-state.ts index 59bf1ae0115..93c76df7289 100644 --- a/src/models/room-state.ts +++ b/src/models/room-state.ts @@ -38,12 +38,14 @@ export enum RoomStateEvent { Events = "RoomState.events", Members = "RoomState.members", NewMember = "RoomState.newMember", + Update = "RoomState.update", // signals batches of updates without specificity } export type RoomStateEventHandlerMap = { [RoomStateEvent.Events]: (event: MatrixEvent, state: RoomState, lastStateEvent: MatrixEvent | null) => void; [RoomStateEvent.Members]: (event: MatrixEvent, state: RoomState, member: RoomMember) => void; [RoomStateEvent.NewMember]: (event: MatrixEvent, state: RoomState, member: RoomMember) => void; + [RoomStateEvent.Update]: (state: RoomState) => void; }; export class RoomState extends TypedEventEmitter { @@ -376,6 +378,8 @@ export class RoomState extends TypedEventEmitter this.setOutOfBandMember(e)); + this.emit(RoomStateEvent.Update, this); } /** diff --git a/src/sync.ts b/src/sync.ts index 043dfc62c04..f275e4f34b3 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -240,6 +240,7 @@ export class SyncApi { RoomStateEvent.Events, RoomStateEvent.Members, RoomStateEvent.NewMember, + RoomStateEvent.Update, ]); room.currentState.on(RoomStateEvent.NewMember, function(event, state, member) { member.user = client.getUser(member.userId);