Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ceb2281

Browse files
authored
Fix regression around replying to search results (#8035)
1 parent 1eb6704 commit ceb2281

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

src/components/structures/RoomView.tsx

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -842,28 +842,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
842842
});
843843
break;
844844
case 'reply_to_event':
845-
if (this.state.searchResults
846-
&& payload.event.getRoomId() === this.state.roomId
847-
&& !this.unmounted
848-
&& payload.context === TimelineRenderingType.Room) {
845+
if (!this.unmounted &&
846+
this.state.searchResults &&
847+
payload.event.getRoomId() === this.state.roomId &&
848+
payload.context === TimelineRenderingType.Search
849+
) {
849850
this.onCancelSearchClick();
850-
}
851-
break;
852-
case 'quote':
853-
if (this.state.searchResults) {
854-
const roomId = payload.event.getRoomId();
855-
if (roomId === this.state.roomId) {
856-
this.onCancelSearchClick();
857-
}
858-
859-
setImmediate(() => {
860-
dis.dispatch<ViewRoomPayload>({
861-
action: Action.ViewRoom,
862-
room_id: roomId,
863-
deferred_action: payload,
864-
metricsTrigger: "MessageSearch",
865-
});
866-
});
851+
// we don't need to re-dispatch as RoomViewStore knows to persist with context=Search also
867852
}
868853
break;
869854
case 'MatrixActions.sync':

src/stores/RoomViewStore.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ class RoomViewStore extends Store<ActionPayload> {
198198
break;
199199
case 'reply_to_event':
200200
// If currently viewed room does not match the room in which we wish to reply then change rooms
201-
// this can happen when performing a search across all rooms
202-
if (payload.context === TimelineRenderingType.Room) {
203-
if (payload.event
204-
&& payload.event.getRoomId() !== this.state.roomId) {
201+
// this can happen when performing a search across all rooms. Persist the data from this event for
202+
// both room and search timeline rendering types, search will get auto-closed by RoomView at this time.
203+
if ([TimelineRenderingType.Room, TimelineRenderingType.Search].includes(payload.context)) {
204+
if (payload.event?.getRoomId() !== this.state.roomId) {
205205
dis.dispatch<ViewRoomPayload>({
206206
action: Action.ViewRoom,
207207
room_id: payload.event.getRoomId(),

0 commit comments

Comments
 (0)