From 6f89267a31386084d0e7a4e3deeca3d6a54dea4c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 5 Jan 2022 15:59:19 +0000 Subject: [PATCH] Fix quoting messages from the search view (#7466) --- src/components/structures/RoomView.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 6943503f01..a20f0e55ae 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -99,6 +99,7 @@ import { fetchInitialEvent } from "../../utils/EventUtils"; import { ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload"; import AppsDrawer from '../views/rooms/AppsDrawer'; import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases'; +import { ActionPayload } from "../../dispatcher/payloads"; const DEBUG = false; let debuglog = function(msg: string) {}; @@ -818,7 +819,7 @@ export class RoomView extends React.Component { this.setState({ callState: call ? call.state : null }); }; - private onAction = payload => { + private onAction = async (payload: ActionPayload): Promise => { switch (payload.action) { case 'message_sent': this.checkDesktopNotifications(); @@ -897,6 +898,12 @@ export class RoomView extends React.Component { case Action.ComposerInsert: { if (payload.composerType) break; + + if (this.state.searching && payload.timelineRenderingType === TimelineRenderingType.Room) { + // we don't have the composer rendered in this state, so bring it back first + await this.onCancelSearchClick(); + } + // re-dispatch to the correct composer dis.dispatch({ ...payload, @@ -1612,10 +1619,12 @@ export class RoomView extends React.Component { }); }; - private onCancelSearchClick = () => { - this.setState({ - searching: false, - searchResults: null, + private onCancelSearchClick = (): Promise => { + return new Promise(resolve => { + this.setState({ + searching: false, + searchResults: null, + }, resolve); }); };