Fix buttons of widget in a room (#12288)

* Revert 3acd648 - Fix timeline position when moving to a room and coming back

* Fix initialEventId
This commit is contained in:
Florian Duros
2024-02-27 13:02:16 +01:00
committed by GitHub
parent 28f7aac9a5
commit 494d9de6f0
5 changed files with 35 additions and 14 deletions

View File

@@ -382,6 +382,10 @@ export class RoomViewStore extends EventEmitter {
this.cancelAskToJoin(payload as CancelAskToJoinPayload);
break;
}
case Action.RoomLoaded: {
this.setViewRoomOpts();
break;
}
}
}
@@ -446,10 +450,6 @@ export class RoomViewStore extends EventEmitter {
return;
}
const viewRoomOpts: ViewRoomOpts = { buttons: [] };
// Allow modules to update the list of buttons for the room by updating `viewRoomOpts`.
ModuleRunner.instance.invoke(RoomViewLifecycle.ViewRoom, viewRoomOpts, this.getRoomId());
const newState: Partial<State> = {
roomId: payload.room_id,
roomAlias: payload.room_alias ?? null,
@@ -472,7 +472,6 @@ export class RoomViewStore extends EventEmitter {
(payload.room_id === this.state.roomId
? this.state.viewingCall
: CallStore.instance.getActiveCall(payload.room_id) !== null),
viewRoomOpts,
};
// Allow being given an event to be replied to when switching rooms but sanity check its for this room
@@ -837,4 +836,15 @@ export class RoomViewStore extends EventEmitter {
public getViewRoomOpts(): ViewRoomOpts {
return this.state.viewRoomOpts;
}
/**
* Invokes the view room lifecycle to set the view room options.
*
* @returns {void}
*/
private setViewRoomOpts(): void {
const viewRoomOpts: ViewRoomOpts = { buttons: [] };
ModuleRunner.instance.invoke(RoomViewLifecycle.ViewRoom, viewRoomOpts, this.getRoomId());
this.setState({ viewRoomOpts });
}
}