From 82c2102ccbfefe246781ee8cd5b63f8e464a602c Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Tue, 26 Oct 2021 12:36:42 -0400 Subject: [PATCH] Respect the roomState right container request for the Jitsi widget (#7033) --- src/stores/widgets/WidgetLayoutStore.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/stores/widgets/WidgetLayoutStore.ts b/src/stores/widgets/WidgetLayoutStore.ts index 5d427a0f1a1..7efc5fb195b 100644 --- a/src/stores/widgets/WidgetLayoutStore.ts +++ b/src/stores/widgets/WidgetLayoutStore.ts @@ -207,15 +207,14 @@ export class WidgetLayoutStore extends ReadyWatchingStore { const isLegacyPinned = !!legacyPinned?.[widget.id]; const defaultContainer = WidgetType.JITSI.matches(widget.type) ? Container.Top : Container.Right; - if (manualContainer === Container.Right) { - rightWidgets.push(widget); - } else if (manualContainer === Container.Top || stateContainer === Container.Top) { - topWidgets.push(widget); + let targetContainer = defaultContainer; + if (!!manualContainer || !!stateContainer) { + targetContainer = (manualContainer) ? manualContainer : stateContainer; } else if (isLegacyPinned && !stateContainer) { - topWidgets.push(widget); - } else { - (defaultContainer === Container.Top ? topWidgets : rightWidgets).push(widget); + // Special legacy case + targetContainer = Container.Top; } + (targetContainer === Container.Top ? topWidgets : rightWidgets).push(widget); } // Trim to MAX_PINNED @@ -423,7 +422,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore { public moveToContainer(room: Room, widget: IApp, toContainer: Container) { const allWidgets = this.getAllWidgets(room); - if (!allWidgets.some(([w])=> w.id === widget.id)) return; // invalid + if (!allWidgets.some(([w]) => w.id === widget.id)) return; // invalid this.updateUserLayout(room, { [widget.id]: { container: toContainer }, });