Skip to content

Commit

Permalink
Fix regression around replying to search results (#8035)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Mar 11, 2022
1 parent 1eb6704 commit ceb2281
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
27 changes: 6 additions & 21 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -842,28 +842,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
});
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();
}
break;
case 'quote':
if (this.state.searchResults) {
const roomId = payload.event.getRoomId();
if (roomId === this.state.roomId) {
this.onCancelSearchClick();
}

setImmediate(() => {
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: roomId,
deferred_action: payload,
metricsTrigger: "MessageSearch",
});
});
// we don't need to re-dispatch as RoomViewStore knows to persist with context=Search also
}
break;
case 'MatrixActions.sync':
Expand Down
8 changes: 4 additions & 4 deletions src/stores/RoomViewStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ class RoomViewStore extends Store<ActionPayload> {
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<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: payload.event.getRoomId(),
Expand Down

0 comments on commit ceb2281

Please sign in to comment.