@@ -304,7 +304,7 @@ export class ClientWidgetApi extends EventEmitter {
304304
305305 private onIframeLoad ( ev : Event ) : void {
306306 if ( this . widget . waitForIframeLoad ) {
307- // If the widget is set to waitForIframeLoad the capabilities immediatly get setup after load.
307+ // If the widget is set to waitForIframeLoad the capabilities immediately get setup after load.
308308 // The client does not wait for the ContentLoaded action.
309309 this . beginCapabilities ( ) ;
310310 } else {
@@ -1095,7 +1095,6 @@ export class ClientWidgetApi extends EventEmitter {
10951095 }
10961096
10971097 private async flushRoomState ( ) : Promise < void > {
1098- const useUpdateState = ( await this . getWidgetVersions ( ) ) . includes ( UnstableApiVersion . MSC2762_UPDATE_STATE ) ;
10991098 try {
11001099 // Only send a single action once all concurrent tasks have completed
11011100 do await Promise . all ( [ ...this . pushRoomStateTasks ] ) ;
@@ -1107,7 +1106,8 @@ export class ClientWidgetApi extends EventEmitter {
11071106 events . push ( ...stateKeyMap . values ( ) ) ;
11081107 }
11091108 }
1110- if ( useUpdateState ) {
1109+ if ( ( await this . getWidgetVersions ( ) ) . includes ( UnstableApiVersion . MSC2762_UPDATE_STATE ) ) {
1110+ // Only send state updates when using UpdateState. Otherwise the SendEvent action will be responsible for state updates.
11111111 await this . transport . send < IUpdateStateToWidgetRequestData > ( WidgetApiToWidgetAction . UpdateState , {
11121112 state : events ,
11131113 } ) ;
@@ -1170,11 +1170,9 @@ export class ClientWidgetApi extends EventEmitter {
11701170 * room state entry.
11711171 * @returns {Promise<void> } Resolves when delivered or if the widget is not
11721172 * able to receive the room state due to permissions, rejects if the
1173- widget failed to handle the update.
1173+ * widget failed to handle the update.
11741174 */
11751175 public async feedStateUpdate ( rawEvent : IRoomEvent ) : Promise < void > {
1176- const useUpdateState = ( await this . getWidgetVersions ( ) ) . includes ( UnstableApiVersion . MSC2762_UPDATE_STATE ) ;
1177-
11781176 if ( rawEvent . state_key === undefined ) throw new Error ( "Not a state event" ) ;
11791177 if (
11801178 ( rawEvent . room_id === this . viewedRoomId || this . canUseRoomTimeline ( rawEvent . room_id ) )
@@ -1183,8 +1181,8 @@ export class ClientWidgetApi extends EventEmitter {
11831181 // Updates could race with the initial push of the room's state
11841182 if ( this . pushRoomStateTasks . size === 0 ) {
11851183 // No initial push tasks are pending; safe to send immediately
1186- if ( useUpdateState ) {
1187- // Only send state updates when using UpdateState. Otherwise we will use SendEvent .
1184+ if ( ( await this . getWidgetVersions ( ) ) . includes ( UnstableApiVersion . MSC2762_UPDATE_STATE ) ) {
1185+ // Only send state updates when using UpdateState. Otherwise the SendEvent action will be responsible for state updates .
11881186 await this . transport . send < IUpdateStateToWidgetRequestData > ( WidgetApiToWidgetAction . UpdateState , {
11891187 state : [ rawEvent ] ,
11901188 } ) ;
0 commit comments