From 7e320e5c7a4287f719691d2b559bcb9f81e943f7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Apr 2024 16:38:15 +0100 Subject: [PATCH 01/17] Take the TAC out of labs! Requires https://github.com/matrix-org/matrix-react-sdk/pull/12438 and ideally https://github.com/matrix-org/matrix-react-sdk/pull/12418 --- .../views/dialogs/devtools/RoomNotifications.tsx | 7 ++----- src/components/views/spaces/SpacePanel.tsx | 7 ++----- src/hooks/useUnreadNotifications.ts | 9 +++------ src/settings/Settings.tsx | 9 --------- src/stores/notifications/RoomNotificationStateStore.ts | 4 +--- 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index 5d03ee7c3a5..397db1fa4bc 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -15,7 +15,7 @@ limitations under the License. */ import { NotificationCountType, Room, Thread, ReceiptType } from "matrix-js-sdk/src/matrix"; -import React, { useContext, useMemo } from "react"; +import React, { useContext } from "react"; import { ReadReceipt } from "matrix-js-sdk/src/models/read-receipt"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; @@ -25,7 +25,6 @@ import { determineUnreadState } from "../../../../RoomNotifs"; import { humanReadableNotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; -import SettingsStore from "../../../../settings/SettingsStore"; function UserReadUpTo({ target }: { target: ReadReceipt }): JSX.Element { const cli = useContext(MatrixClientContext); @@ -66,12 +65,10 @@ function UserReadUpTo({ target }: { target: ReadReceipt }): JSX.Elemen } export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Element { - const tacEnabled = useMemo(() => SettingsStore.getValue("threadsActivityCentre"), []); - const { room } = useContext(DevtoolsContext); const cli = useContext(MatrixClientContext); - const { level, count } = determineUnreadState(room, undefined, !tacEnabled); + const { level, count } = determineUnreadState(room, undefined, false); const [notificationState] = useNotificationState(room); return ( diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx index 429a18e1344..8d3041ff1ed 100644 --- a/src/components/views/spaces/SpacePanel.tsx +++ b/src/components/views/spaces/SpacePanel.tsx @@ -368,8 +368,6 @@ const SpacePanel: React.FC = () => { } }); - const isThreadsActivityCentreEnabled = useSettingValue("threadsActivityCentre"); - return ( {({ onKeyDownHandler, onDragEndHandler }) => ( @@ -426,9 +424,8 @@ const SpacePanel: React.FC = () => { )} - {isThreadsActivityCentreEnabled && ( - - )} + + diff --git a/src/hooks/useUnreadNotifications.ts b/src/hooks/useUnreadNotifications.ts index e0a2f1eeff2..f687ee7f1dd 100644 --- a/src/hooks/useUnreadNotifications.ts +++ b/src/hooks/useUnreadNotifications.ts @@ -15,13 +15,12 @@ limitations under the License. */ import { RoomEvent } from "matrix-js-sdk/src/matrix"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import type { NotificationCount, Room } from "matrix-js-sdk/src/matrix"; import { determineUnreadState } from "../RoomNotifs"; import { NotificationLevel } from "../stores/notifications/NotificationLevel"; import { useEventEmitter } from "./useEventEmitter"; -import SettingsStore from "../settings/SettingsStore"; export const useUnreadNotifications = ( room?: Room, @@ -31,8 +30,6 @@ export const useUnreadNotifications = ( count: number; level: NotificationLevel; } => { - const tacEnabled = useMemo(() => SettingsStore.getValue("threadsActivityCentre"), []); - const [symbol, setSymbol] = useState(null); const [count, setCount] = useState(0); const [level, setLevel] = useState(NotificationLevel.None); @@ -53,11 +50,11 @@ export const useUnreadNotifications = ( useEventEmitter(room, RoomEvent.MyMembership, () => updateNotificationState()); const updateNotificationState = useCallback(() => { - const { symbol, count, level } = determineUnreadState(room, threadId, !tacEnabled); + const { symbol, count, level } = determineUnreadState(room, threadId, false); setSymbol(symbol); setCount(count); setLevel(level); - }, [room, threadId, tacEnabled]); + }, [room, threadId]); useEffect(() => { updateNotificationState(); diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 6be0a6b46fb..2702ab93cc8 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -1148,15 +1148,6 @@ export const SETTINGS: { [setting: string]: ISetting } = { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, default: [], }, - "threadsActivityCentre": { - supportedLevels: LEVELS_ACCOUNT_SETTINGS, - labsGroup: LabGroup.Threads, - controller: new ReloadOnChangeController(), - displayName: _td("labs|threads_activity_centre"), - description: () => _t("labs|threads_activity_centre_description", { brand: SdkConfig.get().brand }), - default: false, - isFeature: true, - }, /** * Enable or disable the release announcement feature */ diff --git a/src/stores/notifications/RoomNotificationStateStore.ts b/src/stores/notifications/RoomNotificationStateStore.ts index f2d10ac4fb1..502d2dcce76 100644 --- a/src/stores/notifications/RoomNotificationStateStore.ts +++ b/src/stores/notifications/RoomNotificationStateStore.ts @@ -42,8 +42,6 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient { private listMap = new Map(); private _globalState = new SummarizedNotificationState(); - private tacEnabled = SettingsStore.getValue("threadsActivityCentre"); - private constructor(dispatcher = defaultDispatcher) { super(dispatcher, {}); SettingsStore.watchSetting("feature_dynamic_room_predecessors", null, () => { @@ -99,7 +97,7 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient { */ public getRoomState(room: Room): RoomNotificationState { if (!this.roomMap.has(room)) { - this.roomMap.set(room, new RoomNotificationState(room, !this.tacEnabled)); + this.roomMap.set(room, new RoomNotificationState(room, false)); } return this.roomMap.get(room)!; } From ac9d038b2a7daf3969631664005edc2c8cdba88b Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Apr 2024 16:41:55 +0100 Subject: [PATCH 02/17] i18n --- src/i18n/strings/en_EN.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 0f353c820a2..d5a3737c212 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1462,8 +1462,6 @@ "sliding_sync_server_no_support": "Your server lacks native support", "sliding_sync_server_specify_proxy": "Your server lacks native support, you must specify a proxy", "sliding_sync_server_support": "Your server has native support", - "threads_activity_centre": "Threads Activity Centre (in development)", - "threads_activity_centre_description": "Warning: Under active development; reloads %(brand)s.", "under_active_development": "Under active development.", "unrealiable_e2e": "Unreliable in encrypted rooms", "video_rooms": "Video rooms", From 9cde13b9cfea1f9efcbd778d56d90a6fc2f8c593 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Apr 2024 17:36:00 +0100 Subject: [PATCH 03/17] Add test method That's needed now we we don't include threads in the notif count in the tests --- test/test-utils/test-utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index b124af4ad11..48a6f7e7dcd 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -622,6 +622,7 @@ export function mkStubRoom( getType: jest.fn().mockReturnValue(undefined), getUnfilteredTimelineSet: jest.fn(), getUnreadNotificationCount: jest.fn(() => 0), + getRoomUnreadNotificationCount: jest.fn().mockReturnValue(0), getVersion: jest.fn().mockReturnValue("1"), hasMembershipState: () => false, isElementVideoRoom: jest.fn().mockReturnValue(false), From f34690f11a789f47b8a8b8c0f2cb8b9d9733b409 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Apr 2024 17:41:55 +0100 Subject: [PATCH 04/17] One less labs setting --- .../views/settings/tabs/user/LabsUserSettingsTab-test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx b/test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx index fd9a92a2253..3239c0f875d 100644 --- a/test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx +++ b/test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx @@ -60,7 +60,7 @@ describe("", () => { // non-beta labs section expect(screen.getByText("Early previews")).toBeInTheDocument(); const labsSections = container.getElementsByClassName("mx_SettingsSubsection"); - expect(labsSections).toHaveLength(11); + expect(labsSections).toHaveLength(10); }); describe("Rust crypto setting", () => { From 69a3beb72f8e01d95c1618bf9452cefb25fb0ff8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Apr 2024 17:48:23 +0100 Subject: [PATCH 05/17] Update snapshot --- .../__snapshots__/SpacePanel-test.tsx.snap | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap b/test/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap index 04c3cbf31fa..9364174fc95 100644 --- a/test/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap +++ b/test/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap @@ -226,6 +226,48 @@ exports[` should show all activated MetaSpaces in the correct orde +
+ + + + +