Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fe2fceb

Browse files
authored
Tidy up timelineRenderingType to be passed over context (#7872)
1 parent f4cd71f commit fe2fceb

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
820820
showReadReceipts={this.props.showReadReceipts}
821821
callEventGrouper={callEventGrouper}
822822
hideSender={this.state.hideSender}
823-
timelineRenderingType={this.context.timelineRenderingType}
824823
/>
825824
</TileErrorBoundary>,
826825
);

src/components/structures/RoomView.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import TopUnreadMessagesBar from "../views/rooms/TopUnreadMessagesBar";
9595
import SpaceStore from "../../stores/spaces/SpaceStore";
9696
import { showThread } from '../../dispatcher/dispatch-actions/threads';
9797
import { fetchInitialEvent } from "../../utils/EventUtils";
98-
import { ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload";
98+
import { ComposerInsertPayload, ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload";
9999
import AppsDrawer from '../views/rooms/AppsDrawer';
100100
import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases';
101101
import { ActionPayload } from "../../dispatcher/payloads";
@@ -154,7 +154,6 @@ export interface IRoomState {
154154
isInitialEventHighlighted?: boolean;
155155
replyToEvent?: MatrixEvent;
156156
numUnreadMessages: number;
157-
searching: boolean;
158157
searchTerm?: string;
159158
searchScope?: SearchScope;
160159
searchResults?: XOR<{}, ISearchResults>;
@@ -243,7 +242,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
243242
shouldPeek: true,
244243
membersLoaded: !llMembers,
245244
numUnreadMessages: 0,
246-
searching: false,
247245
searchResults: null,
248246
callState: null,
249247
guestsCanJoin: false,
@@ -898,14 +896,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
898896
case Action.ComposerInsert: {
899897
if (payload.composerType) break;
900898

901-
if (this.state.searching && payload.timelineRenderingType === TimelineRenderingType.Room) {
899+
if (this.state.timelineRenderingType === TimelineRenderingType.Search &&
900+
payload.timelineRenderingType === TimelineRenderingType.Search
901+
) {
902902
// we don't have the composer rendered in this state, so bring it back first
903903
await this.onCancelSearchClick();
904904
}
905905

906906
// re-dispatch to the correct composer
907-
dis.dispatch({
908-
...payload,
907+
dis.dispatch<ComposerInsertPayload>({
908+
...(payload as ComposerInsertPayload),
909+
timelineRenderingType: TimelineRenderingType.Room,
909910
composerType: this.state.editState ? ComposerType.Edit : ComposerType.Send,
910911
});
911912
break;
@@ -1349,7 +1350,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
13491350

13501351
return searchPromise.then((results) => {
13511352
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+
) {
13531357
logger.error("Discarding stale search results");
13541358
return false;
13551359
}
@@ -1557,14 +1561,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
15571561

15581562
private onSearchClick = () => {
15591563
this.setState({
1560-
searching: !this.state.searching,
1564+
timelineRenderingType: this.state.timelineRenderingType === TimelineRenderingType.Search
1565+
? TimelineRenderingType.Room
1566+
: TimelineRenderingType.Search,
15611567
});
15621568
};
15631569

15641570
private onCancelSearchClick = (): Promise<void> => {
15651571
return new Promise<void>(resolve => {
15661572
this.setState({
1567-
searching: false,
1573+
timelineRenderingType: TimelineRenderingType.Room,
15681574
searchResults: null,
15691575
}, resolve);
15701576
});
@@ -1894,7 +1900,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
18941900

18951901
let aux = null;
18961902
let previewBar;
1897-
if (this.state.searching) {
1903+
if (this.state.timelineRenderingType === TimelineRenderingType.Search) {
18981904
aux = <SearchBar
18991905
searchInProgress={this.state.searchInProgress}
19001906
onCancelClick={this.onCancelSearchClick}

src/components/views/rooms/EventTile.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,6 @@ interface IProps {
322322
// whether or not to display thread info
323323
showThreadInfo?: boolean;
324324

325-
timelineRenderingType?: TimelineRenderingType;
326-
327325
// if specified and `true`, the message his behing
328326
// hidden for moderation from other users but is
329327
// displayed to the current user either because they're
@@ -672,7 +670,7 @@ export default class EventTile extends React.Component<IProps, IState> {
672670
}
673671

674672
private renderThreadInfo(): React.ReactNode {
675-
if (this.props.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
673+
if (this.context.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
676674
return (
677675
<p className="mx_ThreadSummaryIcon">{ _t("From a thread") }</p>
678676
);
@@ -986,11 +984,10 @@ export default class EventTile extends React.Component<IProps, IState> {
986984
}
987985

988986
private onSenderProfileClick = () => {
989-
if (!this.props.timelineRenderingType) return;
990987
dis.dispatch<ComposerInsertPayload>({
991988
action: Action.ComposerInsert,
992989
userId: this.props.mxEvent.getSender(),
993-
timelineRenderingType: this.props.timelineRenderingType,
990+
timelineRenderingType: this.context.timelineRenderingType,
994991
});
995992
};
996993

@@ -1016,7 +1013,7 @@ export default class EventTile extends React.Component<IProps, IState> {
10161013
event_id: this.props.mxEvent.getId(),
10171014
highlighted: true,
10181015
room_id: this.props.mxEvent.getRoomId(),
1019-
metricsTrigger: this.props.timelineRenderingType === TimelineRenderingType.Search
1016+
metricsTrigger: this.context.timelineRenderingType === TimelineRenderingType.Search
10201017
? "MessageSearch"
10211018
: undefined,
10221019
});

src/components/views/rooms/SearchResultTile.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export default class SearchResultTile extends React.Component<IProps> {
122122
isTwelveHour={isTwelveHour}
123123
alwaysShowTimestamps={alwaysShowTimestamps}
124124
enableFlair={enableFlair}
125-
timelineRenderingType={TimelineRenderingType.Search}
126125
lastInSection={lastInSection}
127126
continuation={continuation}
128127
callEventGrouper={this.callEventGroupers.get(mxEv.getContent().call_id)}

src/contexts/RoomContext.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const RoomContext = createContext<IRoomState>({
3535
shouldPeek: true,
3636
membersLoaded: false,
3737
numUnreadMessages: 0,
38-
searching: false,
3938
guestsCanJoin: false,
4039
canPeek: false,
4140
showApps: false,

0 commit comments

Comments
 (0)