Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression around replying to search results #8035

Merged
merged 2 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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