From 4b9382f888e1e37830aebb0baaaf756f9991f9f8 Mon Sep 17 00:00:00 2001 From: Florian D Date: Thu, 13 Feb 2025 11:53:51 +0100 Subject: [PATCH] New room list: hide favourites and people meta spaces (#29241) * feat(new room list)!: hide Favourites and People meta spaces when the new room list is enabled * test(space store): add testcase for new labs flag * feat(quick settings): hide pin to sidebar and more options and add extra margin --- res/css/structures/_QuickSettingsButton.pcss | 6 ++ .../tabs/user/SidebarUserSettingsTab.tsx | 65 +++++++++------ .../views/spaces/QuickSettingsButton.tsx | 83 +++++++++++-------- src/stores/spaces/SpaceStore.ts | 18 +++- test/unit-tests/stores/SpaceStore-test.ts | 11 +++ 5 files changed, 120 insertions(+), 63 deletions(-) diff --git a/res/css/structures/_QuickSettingsButton.pcss b/res/css/structures/_QuickSettingsButton.pcss index 44e0ded064c..52aa2377acd 100644 --- a/res/css/structures/_QuickSettingsButton.pcss +++ b/res/css/structures/_QuickSettingsButton.pcss @@ -104,6 +104,12 @@ Please see LICENSE files in the repository root for full details. } } +.mx_QuickSettingsButton_ContextMenuWrapper_new_room_list { + .mx_QuickThemeSwitcher { + margin-top: var(--cpd-space-2x); + } +} + .mx_QuickSettingsButton_icon { // TODO remove when all icons have fill=currentColor * { diff --git a/src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx b/src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx index 067ec9a1249..ccf717e8816 100644 --- a/src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/SidebarUserSettingsTab.tsx @@ -72,6 +72,9 @@ const SidebarUserSettingsTab: React.FC = () => { PosthogTrackers.trackInteraction("WebSettingsSidebarTabSpacesCheckbox", event, 1); }; + // "Favourites" and "People" meta spaces are not available in the new room list + const newRoomListEnabled = useSettingValue("feature_new_room_list"); + return ( @@ -109,33 +112,43 @@ const SidebarUserSettingsTab: React.FC = () => { - - - - {_t("common|favourites")} - - - {_t("settings|sidebar|metaspaces_favourites_description")} - - + {!newRoomListEnabled && ( + <> + + + + {_t("common|favourites")} + + + {_t("settings|sidebar|metaspaces_favourites_description")} + + - - - - {_t("common|people")} - - - {_t("settings|sidebar|metaspaces_people_description")} - - + + + + {_t("common|people")} + + + {_t("settings|sidebar|metaspaces_people_description")} + + + + )} )} -

- - {_t("quick_settings|metaspace_section")} -

- - - - {_t("common|favourites")} - - - - {_t("common|people")} - - { - closeMenu(); - defaultDispatcher.dispatch({ - action: Action.ViewUserSettings, - initialTabId: UserTab.Sidebar, - }); - }} - > - - {_t("quick_settings|sidebar_settings")} - + {!newRoomListEnabled && ( + <> +

+ + {_t("quick_settings|metaspace_section")} +

+ + + {_t("common|favourites")} + + + + {_t("common|people")} + + { + closeMenu(); + defaultDispatcher.dispatch({ + action: Action.ViewUserSettings, + initialTabId: UserTab.Sidebar, + }); + }} + > + + {_t("quick_settings|sidebar_settings")} + + + )} ); diff --git a/src/stores/spaces/SpaceStore.ts b/src/stores/spaces/SpaceStore.ts index 13179f8c86a..8e8b4cc273e 100644 --- a/src/stores/spaces/SpaceStore.ts +++ b/src/stores/spaces/SpaceStore.ts @@ -162,6 +162,20 @@ export class SpaceStoreClass extends AsyncStoreWithClient { SettingsStore.monitorSetting("feature_dynamic_room_predecessors", null); } + /** + * Get the order of meta spaces to display in the space panel. + * + * This accessor should be removed when the "feature_new_room_list" labs flag is removed. + * "People" and "Favourites" will be removed from the "metaSpaceOrder" array and this filter will no longer be needed. + * @private + */ + private get metaSpaceOrder(): MetaSpace[] { + if (!SettingsStore.getValue("feature_new_room_list")) return metaSpaceOrder; + + // People and Favourites are not shown when the new room list is enabled + return metaSpaceOrder.filter((space) => space !== MetaSpace.People && space !== MetaSpace.Favourites); + } + public get invitedSpaces(): Room[] { return Array.from(this._invitedSpaces); } @@ -1164,7 +1178,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { const oldMetaSpaces = this._enabledMetaSpaces; const enabledMetaSpaces = SettingsStore.getValue("Spaces.enabledMetaSpaces"); - this._enabledMetaSpaces = metaSpaceOrder.filter((k) => enabledMetaSpaces[k]); + this._enabledMetaSpaces = this.metaSpaceOrder.filter((k) => enabledMetaSpaces[k]); this._allRoomsInHome = SettingsStore.getValue("Spaces.allRoomsInHome"); this.sendUserProperties(); @@ -1278,7 +1292,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { case "Spaces.enabledMetaSpaces": { const newValue = SettingsStore.getValue("Spaces.enabledMetaSpaces"); - const enabledMetaSpaces = metaSpaceOrder.filter((k) => newValue[k]); + const enabledMetaSpaces = this.metaSpaceOrder.filter((k) => newValue[k]); if (arrayHasDiff(this._enabledMetaSpaces, enabledMetaSpaces)) { const hadPeopleOrHomeEnabled = this.enabledMetaSpaces.some((s) => { return s === MetaSpace.Home || s === MetaSpace.People; diff --git a/test/unit-tests/stores/SpaceStore-test.ts b/test/unit-tests/stores/SpaceStore-test.ts index 9855b264b55..7471ae118b5 100644 --- a/test/unit-tests/stores/SpaceStore-test.ts +++ b/test/unit-tests/stores/SpaceStore-test.ts @@ -141,6 +141,8 @@ describe("SpaceStore", () => { }); afterEach(async () => { + // Disable the new room list feature flag + await SettingsStore.setValue("feature_new_room_list", null, SettingLevel.DEVICE, false); await testUtils.resetAsyncStoreWithClient(store); }); @@ -1391,6 +1393,15 @@ describe("SpaceStore", () => { removeListener(); }); + it("Favourites and People meta spaces should not be returned when the feature_new_room_list labs flag is enabled", async () => { + // Enable the new room list + await SettingsStore.setValue("feature_new_room_list", null, SettingLevel.DEVICE, true); + + await run(); + // Favourites and People meta spaces should not be returned + expect(SpaceStore.instance.enabledMetaSpaces).toStrictEqual([MetaSpace.Home, MetaSpace.Orphans]); + }); + describe("when feature_dynamic_room_predecessors is not enabled", () => { beforeAll(() => { jest.spyOn(SettingsStore, "getValue").mockImplementation(