Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit cb2c835

Browse files
authored
Fix left panel widgets causing app-wide crash (#7660)
1 parent 7567aeb commit cb2c835

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/components/views/elements/AppTile.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ export default class AppTile extends React.Component<IProps, IState> {
243243
}
244244
this.watchUserReady();
245245

246-
WidgetLayoutStore.instance.on(WidgetLayoutStore.emissionForRoom(this.props.room), this.onWidgetLayoutChange);
246+
if (this.props.room) {
247+
const emitEvent = WidgetLayoutStore.emissionForRoom(this.props.room);
248+
WidgetLayoutStore.instance.on(emitEvent, this.onWidgetLayoutChange);
249+
}
250+
247251
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
248252
this.allowedWidgetsWatchRef = SettingsStore.watchSetting("allowedWidgets", null, this.onAllowedWidgetsChange);
249253
// Widget action listeners
@@ -254,7 +258,11 @@ export default class AppTile extends React.Component<IProps, IState> {
254258
// Widget action listeners
255259
if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
256260

257-
WidgetLayoutStore.instance.off(WidgetLayoutStore.emissionForRoom(this.props.room), this.onWidgetLayoutChange);
261+
if (this.props.room) {
262+
const emitEvent = WidgetLayoutStore.emissionForRoom(this.props.room);
263+
WidgetLayoutStore.instance.off(emitEvent, this.onWidgetLayoutChange);
264+
}
265+
258266
this.roomStoreToken?.remove();
259267
SettingsStore.unwatchSetting(this.allowedWidgetsWatchRef);
260268
OwnProfileStore.instance.removeListener(UPDATE_EVENT, this.onUserReady);

0 commit comments

Comments
 (0)