@@ -95,7 +95,7 @@ import TopUnreadMessagesBar from "../views/rooms/TopUnreadMessagesBar";
95
95
import SpaceStore from "../../stores/spaces/SpaceStore" ;
96
96
import { showThread } from '../../dispatcher/dispatch-actions/threads' ;
97
97
import { fetchInitialEvent } from "../../utils/EventUtils" ;
98
- import { ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload" ;
98
+ import { ComposerInsertPayload , ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload" ;
99
99
import AppsDrawer from '../views/rooms/AppsDrawer' ;
100
100
import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases' ;
101
101
import { ActionPayload } from "../../dispatcher/payloads" ;
@@ -154,7 +154,6 @@ export interface IRoomState {
154
154
isInitialEventHighlighted ?: boolean ;
155
155
replyToEvent ?: MatrixEvent ;
156
156
numUnreadMessages : number ;
157
- searching : boolean ;
158
157
searchTerm ?: string ;
159
158
searchScope ?: SearchScope ;
160
159
searchResults ?: XOR < { } , ISearchResults > ;
@@ -243,7 +242,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
243
242
shouldPeek : true ,
244
243
membersLoaded : ! llMembers ,
245
244
numUnreadMessages : 0 ,
246
- searching : false ,
247
245
searchResults : null ,
248
246
callState : null ,
249
247
guestsCanJoin : false ,
@@ -898,14 +896,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
898
896
case Action . ComposerInsert : {
899
897
if ( payload . composerType ) break ;
900
898
901
- if ( this . state . searching && payload . timelineRenderingType === TimelineRenderingType . Room ) {
899
+ if ( this . state . timelineRenderingType === TimelineRenderingType . Search &&
900
+ payload . timelineRenderingType === TimelineRenderingType . Search
901
+ ) {
902
902
// we don't have the composer rendered in this state, so bring it back first
903
903
await this . onCancelSearchClick ( ) ;
904
904
}
905
905
906
906
// re-dispatch to the correct composer
907
- dis . dispatch ( {
908
- ...payload ,
907
+ dis . dispatch < ComposerInsertPayload > ( {
908
+ ...( payload as ComposerInsertPayload ) ,
909
+ timelineRenderingType : TimelineRenderingType . Room ,
909
910
composerType : this . state . editState ? ComposerType . Edit : ComposerType . Send ,
910
911
} ) ;
911
912
break ;
@@ -1349,7 +1350,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1349
1350
1350
1351
return searchPromise . then ( ( results ) => {
1351
1352
debuglog ( "search complete" ) ;
1352
- if ( this . unmounted || ! this . state . searching || this . searchId != localSearchId ) {
1353
+ if ( this . unmounted ||
1354
+ this . state . timelineRenderingType !== TimelineRenderingType . Search ||
1355
+ this . searchId != localSearchId
1356
+ ) {
1353
1357
logger . error ( "Discarding stale search results" ) ;
1354
1358
return false ;
1355
1359
}
@@ -1557,14 +1561,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1557
1561
1558
1562
private onSearchClick = ( ) => {
1559
1563
this . setState ( {
1560
- searching : ! this . state . searching ,
1564
+ timelineRenderingType : this . state . timelineRenderingType === TimelineRenderingType . Search
1565
+ ? TimelineRenderingType . Room
1566
+ : TimelineRenderingType . Search ,
1561
1567
} ) ;
1562
1568
} ;
1563
1569
1564
1570
private onCancelSearchClick = ( ) : Promise < void > => {
1565
1571
return new Promise < void > ( resolve => {
1566
1572
this . setState ( {
1567
- searching : false ,
1573
+ timelineRenderingType : TimelineRenderingType . Room ,
1568
1574
searchResults : null ,
1569
1575
} , resolve ) ;
1570
1576
} ) ;
@@ -1894,7 +1900,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1894
1900
1895
1901
let aux = null ;
1896
1902
let previewBar ;
1897
- if ( this . state . searching ) {
1903
+ if ( this . state . timelineRenderingType === TimelineRenderingType . Search ) {
1898
1904
aux = < SearchBar
1899
1905
searchInProgress = { this . state . searchInProgress }
1900
1906
onCancelClick = { this . onCancelSearchClick }
0 commit comments