From 75cf379cff65aa966ad3fc1acc5371c96e19c121 Mon Sep 17 00:00:00 2001 From: su-ex Date: Sun, 26 May 2024 10:43:36 +0200 Subject: Bring back showSpaceDMBadges setting, force-enabled for now TODO settings UI Co-authored-by: SpiritCroc --- src/settings/Settings.tsx | 5 +++++ src/stores/spaces/SpaceStore.ts | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 5d06388535..5ca4cbc3e8 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -358,6 +358,11 @@ export const SETTINGS: Settings = { default: true, controller: new ReloadOnChangeController(), }, + "Spaces.showSpaceDMBadges": { + displayName: _td("Show notification badges for People in Spaces"), + supportedLevels: LEVELS_ACCOUNT_SETTINGS, + default: true, + }, // SC settings end "feature_video_rooms": { isFeature: true, diff --git a/src/stores/spaces/SpaceStore.ts b/src/stores/spaces/SpaceStore.ts index 690beaa0b7..fcd7ff659b 100644 --- a/src/stores/spaces/SpaceStore.ts +++ b/src/stores/spaces/SpaceStore.ts @@ -155,9 +155,17 @@ export class SpaceStoreClass extends AsyncStoreWithClient { private _msc3946ProcessDynamicPredecessor: boolean = SettingsStore.getValue("feature_dynamic_room_predecessors"); private _storeReadyDeferred = defer(); + // SC start + private _showSpaceDMBadges = true; + // SC end + public constructor() { super(defaultDispatcher, {}); + // SC start + SettingsStore.monitorSetting("Spaces.showSpaceDMBadges", null); + // SC end + SettingsStore.monitorSetting("Spaces.allRoomsInHome", null); SettingsStore.monitorSetting("Spaces.enabledMetaSpaces", null); SettingsStore.monitorSetting("Spaces.showPeopleInSpace", null); @@ -215,6 +223,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient { return this._allRoomsInHome; } + public get showSpaceDMBadges(): boolean { // SC + return this._showSpaceDMBadges; + } + public setActiveRoomInSpace(space: SpaceKey): void { if (!isMetaSpace(space) && !this.matrixClient?.getRoom(space)?.isSpaceRoom()) return; if (space !== this.activeSpace) this.setActiveSpace(space, false); @@ -724,6 +736,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient { if (room.isSpaceRoom() || !flattenedRoomsForSpace.has(room.roomId)) return false; + if (this.showSpaceDMBadges) { // SC + return true; + } + if (dmBadgeSpace && DMRoomMap.shared().getUserIdForRoomId(room.roomId)) { return s === dmBadgeSpace; } @@ -1301,6 +1317,15 @@ export class SpaceStoreClass extends AsyncStoreWithClient { break; } + case "Spaces.showSpaceDMBadges": { // SC + const newValue = SettingsStore.getValue("Spaces.showSpaceDMBadges"); + if (this.showSpaceDMBadges !== newValue) { + this._showSpaceDMBadges = newValue; + this.rebuildSpaceHierarchy(); // rebuild everything + } + break; + } + case "Spaces.enabledMetaSpaces": { const newValue = SettingsStore.getValue("Spaces.enabledMetaSpaces"); const enabledMetaSpaces = this.metaSpaceOrder.filter((k) => newValue[k]); -- 2.48.1