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

Commit 4132c59

Browse files
committed
Fix regression around replying to search results
1 parent 766b8be commit 4132c59

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/components/structures/RoomView.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +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();
851+
// we don't need to re-dispatch as RoomViewStore knows to persist with context=Search also
850852
}
851853
break;
852854
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)