From c1b33d3e2c4e0faccf52f0a094f991ee1dd75bf6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 27 Jan 2021 14:40:04 -0700 Subject: [PATCH] Fix Jitsi widgets causing localized tile crashes Seems to be that as part of the layout work the timing sequence for when `.getRoom().widgets` will work changed. We can get around this with `initIfNeeded` which will no-op in the worst case. This also includes a copy change to make ended conferences stop lying about where to find the widget. This is work towards https://github.com/vector-im/element-web/issues/15739 --- src/components/views/messages/MJitsiWidgetEvent.tsx | 4 +++- src/stores/WidgetStore.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/views/messages/MJitsiWidgetEvent.tsx b/src/components/views/messages/MJitsiWidgetEvent.tsx index 3ff11f7b6f..6031ede8fa 100644 --- a/src/components/views/messages/MJitsiWidgetEvent.tsx +++ b/src/components/views/messages/MJitsiWidgetEvent.tsx @@ -37,11 +37,13 @@ export default class MJitsiWidgetEvent extends React.PureComponent { const senderName = this.props.mxEvent.sender?.name || this.props.mxEvent.getSender(); const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); const widgetId = this.props.mxEvent.getStateKey(); - const widget = WidgetStore.instance.getRoom(room.roomId).widgets.find(w => w.id === widgetId); + const widget = WidgetStore.instance.getRoom(room.roomId, true).widgets.find(w => w.id === widgetId); let joinCopy = _t('Join the conference at the top of this room'); if (widget && WidgetLayoutStore.instance.isInContainer(room, widget, Container.Right)) { joinCopy = _t('Join the conference from the room information card on the right'); + } else if (!widget) { + joinCopy = null; } if (!url) { diff --git a/src/stores/WidgetStore.ts b/src/stores/WidgetStore.ts index 4ff39aaaee..8961581964 100644 --- a/src/stores/WidgetStore.ts +++ b/src/stores/WidgetStore.ts @@ -154,7 +154,8 @@ export default class WidgetStore extends AsyncStoreWithClient { this.emit(UPDATE_EVENT, roomId); }; - public getRoom = (roomId: string) => { + public getRoom = (roomId: string, initIfNeeded = false) => { + if (initIfNeeded) this.initRoom(roomId); // internally handles "if needed" return this.roomMap.get(roomId); };