From b5785a5bf0a3278a040d69264e1c42acdb1a424b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 28 Nov 2022 14:24:55 +0000 Subject: [PATCH 1/4] Fix test naming --- .../{SearchRoomView-test.tsx => RoomSearchView-test.tsx} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/components/structures/{SearchRoomView-test.tsx => RoomSearchView-test.tsx} (99%) diff --git a/test/components/structures/SearchRoomView-test.tsx b/test/components/structures/RoomSearchView-test.tsx similarity index 99% rename from test/components/structures/SearchRoomView-test.tsx rename to test/components/structures/RoomSearchView-test.tsx index c3b07a148c8..941b9330155 100644 --- a/test/components/structures/SearchRoomView-test.tsx +++ b/test/components/structures/RoomSearchView-test.tsx @@ -38,7 +38,7 @@ jest.mock("../../../src/Searching", () => ({ searchPagination: jest.fn(), })); -describe("", () => { +describe("", () => { const eventMapper = (obj: Partial) => new MatrixEvent(obj); const resizeNotifier = new ResizeNotifier(); let client: MatrixClient; From cd3c29324a951f48cde16b30be1f8c297fee15e7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 28 Nov 2022 14:55:37 +0000 Subject: [PATCH 2/4] Fix search not being cleared when clicking on a result --- src/components/structures/RoomView.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index a73082129b7..072fc2cd9c8 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -534,8 +534,7 @@ export class RoomView extends React.Component { const roomId = this.context.roomViewStore.getRoomId(); const room = this.context.client.getRoom(roomId); - // This convoluted type signature ensures we get IntelliSense *and* correct typing - const newState: Partial & Pick = { + const newState: Partial = { roomId, roomAlias: this.context.roomViewStore.getRoomAlias(), roomLoading: this.context.roomViewStore.isRoomLoading(), @@ -679,11 +678,14 @@ export class RoomView extends React.Component { // Clear the search results when clicking a search result (which changes the // currently scrolled to event, this.state.initialEventId). - if (this.state.initialEventId !== newState.initialEventId) { - newState.searchResults = null; + if (this.state.timelineRenderingType === TimelineRenderingType.Search && + this.state.initialEventId !== newState.initialEventId + ) { + newState.timelineRenderingType = TimelineRenderingType.Room; + newState.search = null; } - this.setState(newState); + this.setState(newState as IRoomState); // At this point, newState.roomId could be null (e.g. the alias might not // have been resolved yet) so anything called here must handle this case. From 97d0a30a4ece5925b3beb58e96b1273b234b0afd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 28 Nov 2022 17:32:26 +0000 Subject: [PATCH 3/4] Update RoomView.tsx --- src/components/structures/RoomView.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 072fc2cd9c8..3a1ac4c0d8e 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -682,7 +682,8 @@ export class RoomView extends React.Component { this.state.initialEventId !== newState.initialEventId ) { newState.timelineRenderingType = TimelineRenderingType.Room; - newState.search = null; + this.state.search?.abortController.abort(); + newState.search = undefined; } this.setState(newState as IRoomState); From 10a741a863694f3f88b66cbcbd904b1a00c0354d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 29 Nov 2022 08:46:20 +0000 Subject: [PATCH 4/4] Update RoomView.tsx --- src/components/structures/RoomView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 3a1ac4c0d8e..b9150624fe3 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -682,7 +682,7 @@ export class RoomView extends React.Component { this.state.initialEventId !== newState.initialEventId ) { newState.timelineRenderingType = TimelineRenderingType.Room; - this.state.search?.abortController.abort(); + this.state.search?.abortController?.abort(); newState.search = undefined; }