From 3e2bf5640e17ff1c096a746089c87f8cf93e174a Mon Sep 17 00:00:00 2001 From: Germain Date: Mon, 30 Jan 2023 12:20:11 +0000 Subject: [PATCH] Update to supportsThreads (#9907) --- src/MatrixClientPeg.ts | 2 +- src/utils/EventUtils.ts | 6 +----- test/Notifier-test.ts | 2 +- test/Unread-test.ts | 2 +- test/components/structures/RoomSearchView-test.tsx | 2 +- test/components/structures/ThreadPanel-test.tsx | 2 +- test/components/structures/ThreadView-test.tsx | 2 +- test/components/structures/TimelinePanel-test.tsx | 4 ++-- .../components/views/right_panel/RoomHeaderButtons-test.tsx | 2 +- test/components/views/rooms/EventTile-test.tsx | 2 +- .../NotificationBadge/UnreadNotificationBadge-test.tsx | 2 +- test/components/views/settings/Notifications-test.tsx | 2 +- test/stores/RoomViewStore-test.ts | 2 +- test/test-utils/test-utils.ts | 2 +- test/utils/EventUtils-test.ts | 2 +- 15 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/MatrixClientPeg.ts b/src/MatrixClientPeg.ts index f674892bf7..19a9eb5fde 100644 --- a/src/MatrixClientPeg.ts +++ b/src/MatrixClientPeg.ts @@ -218,7 +218,7 @@ class MatrixClientPegClass implements IMatrixClientPeg { opts.pendingEventOrdering = PendingEventOrdering.Detached; opts.lazyLoadMembers = true; opts.clientWellKnownPollPeriod = 2 * 60 * 60; // 2 hours - opts.experimentalThreadSupport = SettingsStore.getValue("feature_threadenabled"); + opts.threadSupport = SettingsStore.getValue("feature_threadenabled"); if (SettingsStore.getValue("feature_sliding_sync")) { const proxyUrl = SettingsStore.getValue("feature_sliding_sync_proxy_url"); diff --git a/src/utils/EventUtils.ts b/src/utils/EventUtils.ts index e80ffb83e2..5e650018a0 100644 --- a/src/utils/EventUtils.ts +++ b/src/utils/EventUtils.ts @@ -229,11 +229,7 @@ export async function fetchInitialEvent( initialEvent = null; } - if ( - client.supportsExperimentalThreads() && - initialEvent?.isRelation(THREAD_RELATION_TYPE.name) && - !initialEvent.getThread() - ) { + if (client.supportsThreads() && initialEvent?.isRelation(THREAD_RELATION_TYPE.name) && !initialEvent.getThread()) { const threadId = initialEvent.threadRootId; const room = client.getRoom(roomId); const mapper = client.getEventMapper(); diff --git a/test/Notifier-test.ts b/test/Notifier-test.ts index 20b2c2e361..e2b867ee7f 100644 --- a/test/Notifier-test.ts +++ b/test/Notifier-test.ts @@ -109,7 +109,7 @@ describe("Notifier", () => { decryptEventIfNeeded: jest.fn(), getRoom: jest.fn(), getPushActionsForEvent: jest.fn(), - supportsExperimentalThreads: jest.fn().mockReturnValue(false), + supportsThreads: jest.fn().mockReturnValue(false), }); mockClient.pushRules = { diff --git a/test/Unread-test.ts b/test/Unread-test.ts index 8ff759b142..4cfb7f265a 100644 --- a/test/Unread-test.ts +++ b/test/Unread-test.ts @@ -124,7 +124,7 @@ describe("Unread", () => { const myId = client.getUserId()!; beforeAll(() => { - client.supportsExperimentalThreads = () => true; + client.supportsThreads = () => true; }); beforeEach(() => { diff --git a/test/components/structures/RoomSearchView-test.tsx b/test/components/structures/RoomSearchView-test.tsx index 26786956b5..35e297b7a1 100644 --- a/test/components/structures/RoomSearchView-test.tsx +++ b/test/components/structures/RoomSearchView-test.tsx @@ -48,7 +48,7 @@ describe("", () => { beforeEach(async () => { stubClient(); client = MatrixClientPeg.get(); - client.supportsExperimentalThreads = jest.fn().mockReturnValue(true); + client.supportsThreads = jest.fn().mockReturnValue(true); room = new Room("!room:server", client, client.getUserId()); mocked(client.getRoom).mockReturnValue(room); permalinkCreator = new RoomPermalinkCreator(room, room.roomId); diff --git a/test/components/structures/ThreadPanel-test.tsx b/test/components/structures/ThreadPanel-test.tsx index b868549da4..20c6cf0397 100644 --- a/test/components/structures/ThreadPanel-test.tsx +++ b/test/components/structures/ThreadPanel-test.tsx @@ -161,7 +161,7 @@ describe("ThreadPanel", () => { Thread.setServerSideSupport(FeatureSupport.Stable); Thread.setServerSideListSupport(FeatureSupport.Stable); Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable); - jest.spyOn(mockClient, "supportsExperimentalThreads").mockReturnValue(true); + jest.spyOn(mockClient, "supportsThreads").mockReturnValue(true); room = new Room(ROOM_ID, mockClient, mockClient.getUserId() ?? "", { pendingEventOrdering: PendingEventOrdering.Detached, diff --git a/test/components/structures/ThreadView-test.tsx b/test/components/structures/ThreadView-test.tsx index c578121e46..ef6b195a2d 100644 --- a/test/components/structures/ThreadView-test.tsx +++ b/test/components/structures/ThreadView-test.tsx @@ -117,7 +117,7 @@ describe("ThreadView", () => { stubClient(); mockPlatformPeg(); mockClient = mocked(MatrixClientPeg.get()); - jest.spyOn(mockClient, "supportsExperimentalThreads").mockReturnValue(true); + jest.spyOn(mockClient, "supportsThreads").mockReturnValue(true); room = new Room(ROOM_ID, mockClient, mockClient.getUserId() ?? "", { pendingEventOrdering: PendingEventOrdering.Detached, diff --git a/test/components/structures/TimelinePanel-test.tsx b/test/components/structures/TimelinePanel-test.tsx index e66a015a5c..eaeb19d8ec 100644 --- a/test/components/structures/TimelinePanel-test.tsx +++ b/test/components/structures/TimelinePanel-test.tsx @@ -362,7 +362,7 @@ describe("TimelinePanel", () => { client = MatrixClientPeg.get(); Thread.hasServerSideSupport = FeatureSupport.Stable; - client.supportsExperimentalThreads = () => true; + client.supportsThreads = () => true; const getValueCopy = SettingsStore.getValue; SettingsStore.getValue = jest.fn().mockImplementation((name: string) => { if (name === "feature_threadenabled") return true; @@ -524,7 +524,7 @@ describe("TimelinePanel", () => { const client = MatrixClientPeg.get(); client.isRoomEncrypted = () => true; - client.supportsExperimentalThreads = () => true; + client.supportsThreads = () => true; client.decryptEventIfNeeded = () => Promise.resolve(); const authorId = client.getUserId()!; const room = new Room("roomId", client, authorId, { diff --git a/test/components/views/right_panel/RoomHeaderButtons-test.tsx b/test/components/views/right_panel/RoomHeaderButtons-test.tsx index 06192ccc23..8df11a7602 100644 --- a/test/components/views/right_panel/RoomHeaderButtons-test.tsx +++ b/test/components/views/right_panel/RoomHeaderButtons-test.tsx @@ -38,7 +38,7 @@ describe("RoomHeaderButtons-test.tsx", function () { stubClient(); client = MatrixClientPeg.get(); - client.supportsExperimentalThreads = () => true; + client.supportsThreads = () => true; room = new Room(ROOM_ID, client, client.getUserId() ?? "", { pendingEventOrdering: PendingEventOrdering.Detached, }); diff --git a/test/components/views/rooms/EventTile-test.tsx b/test/components/views/rooms/EventTile-test.tsx index c3c0b55ab5..e3f28d851a 100644 --- a/test/components/views/rooms/EventTile-test.tsx +++ b/test/components/views/rooms/EventTile-test.tsx @@ -92,7 +92,7 @@ describe("EventTile", () => { describe("EventTile thread summary", () => { beforeEach(() => { - jest.spyOn(client, "supportsExperimentalThreads").mockReturnValue(true); + jest.spyOn(client, "supportsThreads").mockReturnValue(true); }); it("removes the thread summary when thread is deleted", async () => { diff --git a/test/components/views/rooms/NotificationBadge/UnreadNotificationBadge-test.tsx b/test/components/views/rooms/NotificationBadge/UnreadNotificationBadge-test.tsx index cfa4416576..9c60d26e26 100644 --- a/test/components/views/rooms/NotificationBadge/UnreadNotificationBadge-test.tsx +++ b/test/components/views/rooms/NotificationBadge/UnreadNotificationBadge-test.tsx @@ -48,7 +48,7 @@ describe("UnreadNotificationBadge", () => { } beforeAll(() => { - client.supportsExperimentalThreads = () => true; + client.supportsThreads = () => true; }); beforeEach(() => { diff --git a/test/components/views/settings/Notifications-test.tsx b/test/components/views/settings/Notifications-test.tsx index b33f72838a..aedb96fb13 100644 --- a/test/components/views/settings/Notifications-test.tsx +++ b/test/components/views/settings/Notifications-test.tsx @@ -225,7 +225,7 @@ describe("", () => { }), setAccountData: jest.fn(), sendReadReceipt: jest.fn(), - supportsExperimentalThreads: jest.fn().mockReturnValue(true), + supportsThreads: jest.fn().mockReturnValue(true), }); mockClient.getPushRules.mockResolvedValue(pushRules); diff --git a/test/stores/RoomViewStore-test.ts b/test/stores/RoomViewStore-test.ts index 7c2b1ec81b..370fb95bcd 100644 --- a/test/stores/RoomViewStore-test.ts +++ b/test/stores/RoomViewStore-test.ts @@ -93,7 +93,7 @@ describe("RoomViewStore", function () { getSafeUserId: jest.fn().mockReturnValue(userId), getDeviceId: jest.fn().mockReturnValue("ABC123"), sendStateEvent: jest.fn().mockResolvedValue({}), - supportsExperimentalThreads: jest.fn(), + supportsThreads: jest.fn(), }); const room = new Room(roomId, mockClient, userId); const room2 = new Room(roomId2, mockClient, userId); diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index ef7bc1dcef..5938f89cfe 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -166,7 +166,7 @@ export function createTestClient(): MatrixClient { decryptEventIfNeeded: () => Promise.resolve(), isUserIgnored: jest.fn().mockReturnValue(false), getCapabilities: jest.fn().mockResolvedValue({}), - supportsExperimentalThreads: () => false, + supportsThreads: () => false, getRoomUpgradeHistory: jest.fn().mockReturnValue([]), getOpenIdToken: jest.fn().mockResolvedValue(undefined), registerWithIdentityServer: jest.fn().mockResolvedValue({}), diff --git a/test/utils/EventUtils-test.ts b/test/utils/EventUtils-test.ts index decf42931a..9c4012a4c4 100644 --- a/test/utils/EventUtils-test.ts +++ b/test/utils/EventUtils-test.ts @@ -436,7 +436,7 @@ describe("EventUtils", () => { pendingEventOrdering: PendingEventOrdering.Detached, }); - jest.spyOn(client, "supportsExperimentalThreads").mockReturnValue(true); + jest.spyOn(client, "supportsThreads").mockReturnValue(true); jest.spyOn(client, "getRoom").mockReturnValue(room); jest.spyOn(client, "fetchRoomEvent").mockImplementation(async (roomId, eventId) => { return events[eventId] ?? Promise.reject();