schildichat-desktop/patches/element-web/0013-Bring-back-showSpaceDMBadges-setting-force-enabled-f.patch

93 lines
3.7 KiB
Diff

From 1a73e666d193a583aa025fb75a9afdf59f1d36fa Mon Sep 17 00:00:00 2001
From: su-ex <codeworks@supercable.onl>
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 <dev@spiritcroc.de>
---
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 ae4b0ea644..12d9965cf1 100644
--- a/src/settings/Settings.tsx
+++ b/src/settings/Settings.tsx
@@ -199,6 +199,11 @@ export const SETTINGS: { [setting: string]: ISetting } = {
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 90358f3310..60df05478a 100644
--- a/src/stores/spaces/SpaceStore.ts
+++ b/src/stores/spaces/SpaceStore.ts
@@ -154,9 +154,17 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
/** Whether the feature flag is set for MSC3946 */
private _msc3946ProcessDynamicPredecessor: boolean = SettingsStore.getValue("feature_dynamic_room_predecessors");
+ // 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);
@@ -192,6 +200,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
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);
@@ -701,6 +713,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
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;
}
@@ -1277,6 +1293,15 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
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 = metaSpaceOrder.filter((k) => newValue[k]);
--
2.47.0