From 148764aa8a8c23f282d7512956db515a7b64964f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 Feb 2021 13:50:49 +0000 Subject: [PATCH 1/4] Create Labs flag for Spaces --- src/settings/Settings.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 9ad0e8987e..a8fa88179b 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -120,6 +120,13 @@ export interface ISetting { } export const SETTINGS: {[setting: string]: ISetting} = { + "feature_spaces": { + isFeature: true, + displayName: _td("Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags"), + supportedLevels: LEVELS_FEATURE, + default: false, + controller: new ReloadOnChangeController(), + }, "feature_latex_maths": { isFeature: true, displayName: _td("Render LaTeX maths in messages"), @@ -134,6 +141,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { ), supportedLevels: LEVELS_FEATURE, default: false, + controller: new IncompatibleController("feature_spaces"), }, "feature_new_spinner": { isFeature: true, @@ -159,6 +167,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { displayName: _td("Group & filter rooms by custom tags (refresh to apply changes)"), supportedLevels: LEVELS_FEATURE, default: false, + controller: new IncompatibleController("feature_spaces"), }, "feature_state_counters": { isFeature: true, @@ -733,6 +742,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { [UIFeature.Communities]: { supportedLevels: LEVELS_UI_FEATURE, default: true, + controller: new IncompatibleController("feature_spaces"), }, [UIFeature.AdvancedSettings]: { supportedLevels: LEVELS_UI_FEATURE, From 6b3f05a3cdd58311875b0ad17f38c1cdc3331ef3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 Feb 2021 14:10:36 +0000 Subject: [PATCH 2/4] Switch RoomListStore to only including the filtered subset Without this it'd include notification counts from Community B when Community A is selected and such. --- src/stores/room-list/RoomListStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stores/room-list/RoomListStore.ts b/src/stores/room-list/RoomListStore.ts index ea118a4c58..667d9de64d 100644 --- a/src/stores/room-list/RoomListStore.ts +++ b/src/stores/room-list/RoomListStore.ts @@ -58,8 +58,8 @@ export class RoomListStoreClass extends AsyncStoreWithClient { private filterConditions: IFilterCondition[] = []; private tagWatcher = new TagWatcher(this); private updateFn = new MarkedExecution(() => { - for (const tagId of Object.keys(this.unfilteredLists)) { - RoomNotificationStateStore.instance.getListState(tagId).setRooms(this.unfilteredLists[tagId]); + for (const tagId of Object.keys(this.orderedLists)) { + RoomNotificationStateStore.instance.getListState(tagId).setRooms(this.orderedLists[tagId]); } this.emit(LISTS_UPDATE_EVENT); }); From 79daf615e4d8f99602c2c616baebf8d359a3e39e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 Feb 2021 14:20:57 +0000 Subject: [PATCH 3/4] First special treatment of space-rooms --- src/Avatar.ts | 3 +++ src/i18n/strings/en_EN.json | 1 + src/stores/BreadcrumbsStore.ts | 1 + .../room-list/filters/VisibilityProvider.ts | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Avatar.ts b/src/Avatar.ts index 60bdfdcf75..e2557e21a8 100644 --- a/src/Avatar.ts +++ b/src/Avatar.ts @@ -165,6 +165,9 @@ export function avatarUrlForRoom(room: Room, width: number, height: number, resi return explicitRoomAvatar; } + // space rooms cannot be DMs so skip the rest + if (room.isSpaceRoom()) return null; + let otherMember = null; const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId); if (otherUserId) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c3038fd9af..77451c1da8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -777,6 +777,7 @@ "%(senderName)s: %(reaction)s": "%(senderName)s: %(reaction)s", "%(senderName)s: %(stickerName)s": "%(senderName)s: %(stickerName)s", "Change notification settings": "Change notification settings", + "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags": "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags", "Render LaTeX maths in messages": "Render LaTeX maths in messages", "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.": "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.", "New spinner design": "New spinner design", diff --git a/src/stores/BreadcrumbsStore.ts b/src/stores/BreadcrumbsStore.ts index 24906f678c..393f4f27a1 100644 --- a/src/stores/BreadcrumbsStore.ts +++ b/src/stores/BreadcrumbsStore.ts @@ -122,6 +122,7 @@ export class BreadcrumbsStore extends AsyncStoreWithClient { } private async appendRoom(room: Room) { + if (room.isSpaceRoom() && SettingsStore.getValue("feature_spaces")) return; // hide space rooms let updated = false; const rooms = (this.state.rooms || []).slice(); // cheap clone diff --git a/src/stores/room-list/filters/VisibilityProvider.ts b/src/stores/room-list/filters/VisibilityProvider.ts index af38141e5d..388bb061e3 100644 --- a/src/stores/room-list/filters/VisibilityProvider.ts +++ b/src/stores/room-list/filters/VisibilityProvider.ts @@ -18,6 +18,7 @@ import {Room} from "matrix-js-sdk/src/models/room"; import CallHandler from "../../../CallHandler"; import { RoomListCustomisations } from "../../../customisations/RoomList"; import VoipUserMapper from "../../../VoipUserMapper"; +import SettingsStore from "../../../settings/SettingsStore"; export class VisibilityProvider { private static internalInstance: VisibilityProvider; @@ -37,22 +38,23 @@ export class VisibilityProvider { } public isRoomVisible(room: Room): boolean { - let isVisible = true; // Returned at the end of this function - let forced = false; // When true, this function won't bother calling the customisation points - if ( CallHandler.sharedInstance().getSupportsVirtualRooms() && VoipUserMapper.sharedInstance().isVirtualRoom(room) ) { - isVisible = false; - forced = true; + return false; + } + + // hide space rooms as they'll be shown in the SpacePanel + if (room.isSpaceRoom() && SettingsStore.getValue("feature_spaces")) { + return false; } const isVisibleFn = RoomListCustomisations.isRoomVisible; - if (!forced && isVisibleFn) { - isVisible = isVisibleFn(room); + if (isVisibleFn) { + return isVisibleFn(room); } - return isVisible; + return true; // default } } From 864a9974b1fe6015d56c6bf1987e19a354b3378d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Feb 2021 12:20:10 +0000 Subject: [PATCH 4/4] Tweak spaces labs flag copy --- src/i18n/strings/en_EN.json | 2 +- src/settings/Settings.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 77451c1da8..973c426420 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -777,7 +777,7 @@ "%(senderName)s: %(reaction)s": "%(senderName)s: %(reaction)s", "%(senderName)s: %(stickerName)s": "%(senderName)s: %(stickerName)s", "Change notification settings": "Change notification settings", - "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags": "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags", + "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. Requires compatible homeserver for some features.": "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. Requires compatible homeserver for some features.", "Render LaTeX maths in messages": "Render LaTeX maths in messages", "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.": "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.", "New spinner design": "New spinner design", diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index a8fa88179b..b452f10e73 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -122,7 +122,8 @@ export interface ISetting { export const SETTINGS: {[setting: string]: ISetting} = { "feature_spaces": { isFeature: true, - displayName: _td("Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags"), + displayName: _td("Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. " + + "Requires compatible homeserver for some features."), supportedLevels: LEVELS_FEATURE, default: false, controller: new ReloadOnChangeController(),