From bba7ae1e49d0a76b99f89da6a854ab75437d8a92 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 24 Jan 2022 17:18:03 +0000 Subject: [PATCH] Add labs flag for default open right panel This adds an experimental default open right panel mode as a quick fix for those who prefer to have the right panel open consistently across rooms. If no right panel state is known for the room or it was closed on the last room visit, it will default to the room member list. Otherwise, the saved card last used in that room is shown. Fixes https://github.com/vector-im/element-web/issues/20666 --- src/i18n/strings/en_EN.json | 1 + src/settings/Settings.tsx | 7 +++++++ src/stores/right-panel/RightPanelStore.ts | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bc8f8a60d41..5ea96acaadb 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -889,6 +889,7 @@ "Meta Spaces": "Meta Spaces", "Use new room breadcrumbs": "Use new room breadcrumbs", "New spotlight search experience": "New spotlight search experience", + "Right panel stays open (defaults to room member list)": "Right panel stays open (defaults to room member list)", "Jump to date (adds /jumptodate)": "Jump to date (adds /jumptodate)", "Don't send read receipts": "Don't send read receipts", "Font size": "Font size", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 6e92200f0b3..b84679f3c82 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -366,6 +366,13 @@ export const SETTINGS: {[setting: string]: ISetting} = { displayName: _td("New spotlight search experience"), default: false, }, + "feature_right_panel_default_open": { + isFeature: true, + labsGroup: LabGroup.Rooms, + supportedLevels: LEVELS_FEATURE, + displayName: _td("Right panel stays open (defaults to room member list)"), + default: false, + }, "feature_jump_to_date": { // We purposely leave out `isFeature: true` so it doesn't show in Labs // by default. We will conditionally show it depending on whether we can diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index 49a5dfbd511..682cd43dcc2 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -368,6 +368,21 @@ export default class RightPanelStore extends ReadyWatchingStore { this.isViewingRoom = true; // Is viewing room will of course be removed when removing groups // load values from byRoomCache with the viewedRoomId. this.loadCacheFromSettings(); + // If the right panel stays open mode is used, and the panel was either + // closed or never shown for that room, then force it open and display + // the room member list. + if ( + SettingsStore.getValue("feature_right_panel_default_open") && + !this.byRoom[this.viewedRoomId]?.isOpen + ) { + this.byRoom[this.viewedRoomId] = { + isOpen: true, + history: [ + { phase: RightPanelPhases.RoomSummary }, + { phase: RightPanelPhases.RoomMemberList }, + ], + }; + } this.emitAndUpdateSettings(); };