From 766b8befb1b1c9a2fca4710c0c6ef41a26fbf9bd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 11 Mar 2022 12:19:32 +0000 Subject: [PATCH 1/2] Remove unused code-path --- src/components/structures/RoomView.tsx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index cbfe8d0c2e9..081056f8a86 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -849,23 +849,6 @@ export class RoomView extends React.Component { this.onCancelSearchClick(); } break; - case 'quote': - if (this.state.searchResults) { - const roomId = payload.event.getRoomId(); - if (roomId === this.state.roomId) { - this.onCancelSearchClick(); - } - - setImmediate(() => { - dis.dispatch({ - action: Action.ViewRoom, - room_id: roomId, - deferred_action: payload, - metricsTrigger: "MessageSearch", - }); - }); - } - break; case 'MatrixActions.sync': if (!this.state.matrixClientIsReady) { this.setState({ From 4132c59cda4a0c73c5ddd626239cc5fdaa474e49 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 11 Mar 2022 12:25:24 +0000 Subject: [PATCH 2/2] Fix regression around replying to search results --- src/components/structures/RoomView.tsx | 10 ++++++---- src/stores/RoomViewStore.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 081056f8a86..e57184604c5 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -842,11 +842,13 @@ export class RoomView extends React.Component { }); break; case 'reply_to_event': - if (this.state.searchResults - && payload.event.getRoomId() === this.state.roomId - && !this.unmounted - && payload.context === TimelineRenderingType.Room) { + if (!this.unmounted && + this.state.searchResults && + payload.event.getRoomId() === this.state.roomId && + payload.context === TimelineRenderingType.Search + ) { this.onCancelSearchClick(); + // we don't need to re-dispatch as RoomViewStore knows to persist with context=Search also } break; case 'MatrixActions.sync': diff --git a/src/stores/RoomViewStore.tsx b/src/stores/RoomViewStore.tsx index 66d045d11d0..d6ee527f8bd 100644 --- a/src/stores/RoomViewStore.tsx +++ b/src/stores/RoomViewStore.tsx @@ -198,10 +198,10 @@ class RoomViewStore extends Store { break; case 'reply_to_event': // If currently viewed room does not match the room in which we wish to reply then change rooms - // this can happen when performing a search across all rooms - if (payload.context === TimelineRenderingType.Room) { - if (payload.event - && payload.event.getRoomId() !== this.state.roomId) { + // this can happen when performing a search across all rooms. Persist the data from this event for + // both room and search timeline rendering types, search will get auto-closed by RoomView at this time. + if ([TimelineRenderingType.Room, TimelineRenderingType.Search].includes(payload.context)) { + if (payload.event?.getRoomId() !== this.state.roomId) { dis.dispatch({ action: Action.ViewRoom, room_id: payload.event.getRoomId(),