Fix regression around replying to search results (#8035)

This commit is contained in:
Michael Telatynski 2022-03-11 15:40:49 +00:00 committed by GitHub
parent 1eb67047c9
commit ceb2281d36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 25 deletions

View file

@ -842,28 +842,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
}); });
break; break;
case 'reply_to_event': case 'reply_to_event':
if (this.state.searchResults if (!this.unmounted &&
&& payload.event.getRoomId() === this.state.roomId this.state.searchResults &&
&& !this.unmounted payload.event.getRoomId() === this.state.roomId &&
&& payload.context === TimelineRenderingType.Room) { payload.context === TimelineRenderingType.Search
) {
this.onCancelSearchClick(); this.onCancelSearchClick();
} // we don't need to re-dispatch as RoomViewStore knows to persist with context=Search also
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",
});
});
} }
break; break;
case 'MatrixActions.sync': case 'MatrixActions.sync':

View file

@ -198,10 +198,10 @@ class RoomViewStore extends Store<ActionPayload> {
break; break;
case 'reply_to_event': case 'reply_to_event':
// If currently viewed room does not match the room in which we wish to reply then change rooms // 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 // this can happen when performing a search across all rooms. Persist the data from this event for
if (payload.context === TimelineRenderingType.Room) { // both room and search timeline rendering types, search will get auto-closed by RoomView at this time.
if (payload.event if ([TimelineRenderingType.Room, TimelineRenderingType.Search].includes(payload.context)) {
&& payload.event.getRoomId() !== this.state.roomId) { if (payload.event?.getRoomId() !== this.state.roomId) {
dis.dispatch<ViewRoomPayload>({ dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom, action: Action.ViewRoom,
room_id: payload.event.getRoomId(), room_id: payload.event.getRoomId(),