Tidy up timelineRenderingType to be passed over context (#7872)
parent
f4cd71fd47
commit
fe2fceb0ba
|
@ -820,7 +820,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
||||||
showReadReceipts={this.props.showReadReceipts}
|
showReadReceipts={this.props.showReadReceipts}
|
||||||
callEventGrouper={callEventGrouper}
|
callEventGrouper={callEventGrouper}
|
||||||
hideSender={this.state.hideSender}
|
hideSender={this.state.hideSender}
|
||||||
timelineRenderingType={this.context.timelineRenderingType}
|
|
||||||
/>
|
/>
|
||||||
</TileErrorBoundary>,
|
</TileErrorBoundary>,
|
||||||
);
|
);
|
||||||
|
|
|
@ -95,7 +95,7 @@ import TopUnreadMessagesBar from "../views/rooms/TopUnreadMessagesBar";
|
||||||
import SpaceStore from "../../stores/spaces/SpaceStore";
|
import SpaceStore from "../../stores/spaces/SpaceStore";
|
||||||
import { showThread } from '../../dispatcher/dispatch-actions/threads';
|
import { showThread } from '../../dispatcher/dispatch-actions/threads';
|
||||||
import { fetchInitialEvent } from "../../utils/EventUtils";
|
import { fetchInitialEvent } from "../../utils/EventUtils";
|
||||||
import { ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload";
|
import { ComposerInsertPayload, ComposerType } from "../../dispatcher/payloads/ComposerInsertPayload";
|
||||||
import AppsDrawer from '../views/rooms/AppsDrawer';
|
import AppsDrawer from '../views/rooms/AppsDrawer';
|
||||||
import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases';
|
import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases';
|
||||||
import { ActionPayload } from "../../dispatcher/payloads";
|
import { ActionPayload } from "../../dispatcher/payloads";
|
||||||
|
@ -154,7 +154,6 @@ export interface IRoomState {
|
||||||
isInitialEventHighlighted?: boolean;
|
isInitialEventHighlighted?: boolean;
|
||||||
replyToEvent?: MatrixEvent;
|
replyToEvent?: MatrixEvent;
|
||||||
numUnreadMessages: number;
|
numUnreadMessages: number;
|
||||||
searching: boolean;
|
|
||||||
searchTerm?: string;
|
searchTerm?: string;
|
||||||
searchScope?: SearchScope;
|
searchScope?: SearchScope;
|
||||||
searchResults?: XOR<{}, ISearchResults>;
|
searchResults?: XOR<{}, ISearchResults>;
|
||||||
|
@ -243,7 +242,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
shouldPeek: true,
|
shouldPeek: true,
|
||||||
membersLoaded: !llMembers,
|
membersLoaded: !llMembers,
|
||||||
numUnreadMessages: 0,
|
numUnreadMessages: 0,
|
||||||
searching: false,
|
|
||||||
searchResults: null,
|
searchResults: null,
|
||||||
callState: null,
|
callState: null,
|
||||||
guestsCanJoin: false,
|
guestsCanJoin: false,
|
||||||
|
@ -898,14 +896,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
case Action.ComposerInsert: {
|
case Action.ComposerInsert: {
|
||||||
if (payload.composerType) break;
|
if (payload.composerType) break;
|
||||||
|
|
||||||
if (this.state.searching && payload.timelineRenderingType === TimelineRenderingType.Room) {
|
if (this.state.timelineRenderingType === TimelineRenderingType.Search &&
|
||||||
|
payload.timelineRenderingType === TimelineRenderingType.Search
|
||||||
|
) {
|
||||||
// we don't have the composer rendered in this state, so bring it back first
|
// we don't have the composer rendered in this state, so bring it back first
|
||||||
await this.onCancelSearchClick();
|
await this.onCancelSearchClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-dispatch to the correct composer
|
// re-dispatch to the correct composer
|
||||||
dis.dispatch({
|
dis.dispatch<ComposerInsertPayload>({
|
||||||
...payload,
|
...(payload as ComposerInsertPayload),
|
||||||
|
timelineRenderingType: TimelineRenderingType.Room,
|
||||||
composerType: this.state.editState ? ComposerType.Edit : ComposerType.Send,
|
composerType: this.state.editState ? ComposerType.Edit : ComposerType.Send,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -1349,7 +1350,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
|
|
||||||
return searchPromise.then((results) => {
|
return searchPromise.then((results) => {
|
||||||
debuglog("search complete");
|
debuglog("search complete");
|
||||||
if (this.unmounted || !this.state.searching || this.searchId != localSearchId) {
|
if (this.unmounted ||
|
||||||
|
this.state.timelineRenderingType !== TimelineRenderingType.Search ||
|
||||||
|
this.searchId != localSearchId
|
||||||
|
) {
|
||||||
logger.error("Discarding stale search results");
|
logger.error("Discarding stale search results");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1557,14 +1561,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
|
|
||||||
private onSearchClick = () => {
|
private onSearchClick = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
searching: !this.state.searching,
|
timelineRenderingType: this.state.timelineRenderingType === TimelineRenderingType.Search
|
||||||
|
? TimelineRenderingType.Room
|
||||||
|
: TimelineRenderingType.Search,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private onCancelSearchClick = (): Promise<void> => {
|
private onCancelSearchClick = (): Promise<void> => {
|
||||||
return new Promise<void>(resolve => {
|
return new Promise<void>(resolve => {
|
||||||
this.setState({
|
this.setState({
|
||||||
searching: false,
|
timelineRenderingType: TimelineRenderingType.Room,
|
||||||
searchResults: null,
|
searchResults: null,
|
||||||
}, resolve);
|
}, resolve);
|
||||||
});
|
});
|
||||||
|
@ -1894,7 +1900,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
|
|
||||||
let aux = null;
|
let aux = null;
|
||||||
let previewBar;
|
let previewBar;
|
||||||
if (this.state.searching) {
|
if (this.state.timelineRenderingType === TimelineRenderingType.Search) {
|
||||||
aux = <SearchBar
|
aux = <SearchBar
|
||||||
searchInProgress={this.state.searchInProgress}
|
searchInProgress={this.state.searchInProgress}
|
||||||
onCancelClick={this.onCancelSearchClick}
|
onCancelClick={this.onCancelSearchClick}
|
||||||
|
|
|
@ -322,8 +322,6 @@ interface IProps {
|
||||||
// whether or not to display thread info
|
// whether or not to display thread info
|
||||||
showThreadInfo?: boolean;
|
showThreadInfo?: boolean;
|
||||||
|
|
||||||
timelineRenderingType?: TimelineRenderingType;
|
|
||||||
|
|
||||||
// if specified and `true`, the message his behing
|
// if specified and `true`, the message his behing
|
||||||
// hidden for moderation from other users but is
|
// hidden for moderation from other users but is
|
||||||
// displayed to the current user either because they're
|
// displayed to the current user either because they're
|
||||||
|
@ -672,7 +670,7 @@ export default class EventTile extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderThreadInfo(): React.ReactNode {
|
private renderThreadInfo(): React.ReactNode {
|
||||||
if (this.props.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
|
if (this.context.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
|
||||||
return (
|
return (
|
||||||
<p className="mx_ThreadSummaryIcon">{ _t("From a thread") }</p>
|
<p className="mx_ThreadSummaryIcon">{ _t("From a thread") }</p>
|
||||||
);
|
);
|
||||||
|
@ -986,11 +984,10 @@ export default class EventTile extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSenderProfileClick = () => {
|
private onSenderProfileClick = () => {
|
||||||
if (!this.props.timelineRenderingType) return;
|
|
||||||
dis.dispatch<ComposerInsertPayload>({
|
dis.dispatch<ComposerInsertPayload>({
|
||||||
action: Action.ComposerInsert,
|
action: Action.ComposerInsert,
|
||||||
userId: this.props.mxEvent.getSender(),
|
userId: this.props.mxEvent.getSender(),
|
||||||
timelineRenderingType: this.props.timelineRenderingType,
|
timelineRenderingType: this.context.timelineRenderingType,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1016,7 +1013,7 @@ export default class EventTile extends React.Component<IProps, IState> {
|
||||||
event_id: this.props.mxEvent.getId(),
|
event_id: this.props.mxEvent.getId(),
|
||||||
highlighted: true,
|
highlighted: true,
|
||||||
room_id: this.props.mxEvent.getRoomId(),
|
room_id: this.props.mxEvent.getRoomId(),
|
||||||
metricsTrigger: this.props.timelineRenderingType === TimelineRenderingType.Search
|
metricsTrigger: this.context.timelineRenderingType === TimelineRenderingType.Search
|
||||||
? "MessageSearch"
|
? "MessageSearch"
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
|
|
|
@ -122,7 +122,6 @@ export default class SearchResultTile extends React.Component<IProps> {
|
||||||
isTwelveHour={isTwelveHour}
|
isTwelveHour={isTwelveHour}
|
||||||
alwaysShowTimestamps={alwaysShowTimestamps}
|
alwaysShowTimestamps={alwaysShowTimestamps}
|
||||||
enableFlair={enableFlair}
|
enableFlair={enableFlair}
|
||||||
timelineRenderingType={TimelineRenderingType.Search}
|
|
||||||
lastInSection={lastInSection}
|
lastInSection={lastInSection}
|
||||||
continuation={continuation}
|
continuation={continuation}
|
||||||
callEventGrouper={this.callEventGroupers.get(mxEv.getContent().call_id)}
|
callEventGrouper={this.callEventGroupers.get(mxEv.getContent().call_id)}
|
||||||
|
|
|
@ -35,7 +35,6 @@ const RoomContext = createContext<IRoomState>({
|
||||||
shouldPeek: true,
|
shouldPeek: true,
|
||||||
membersLoaded: false,
|
membersLoaded: false,
|
||||||
numUnreadMessages: 0,
|
numUnreadMessages: 0,
|
||||||
searching: false,
|
|
||||||
guestsCanJoin: false,
|
guestsCanJoin: false,
|
||||||
canPeek: false,
|
canPeek: false,
|
||||||
showApps: false,
|
showApps: false,
|
||||||
|
|
Loading…
Reference in New Issue