You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Tidy up timelineRenderingType to be passed over context (#7872)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							f4cd71fd47
						
					
				
				
					commit
					fe2fceb0ba
				
			@@ -820,7 +820,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
 | 
			
		||||
                    showReadReceipts={this.props.showReadReceipts}
 | 
			
		||||
                    callEventGrouper={callEventGrouper}
 | 
			
		||||
                    hideSender={this.state.hideSender}
 | 
			
		||||
                    timelineRenderingType={this.context.timelineRenderingType}
 | 
			
		||||
                />
 | 
			
		||||
            </TileErrorBoundary>,
 | 
			
		||||
        );
 | 
			
		||||
 
 | 
			
		||||
@@ -95,7 +95,7 @@ import TopUnreadMessagesBar from "../views/rooms/TopUnreadMessagesBar";
 | 
			
		||||
import SpaceStore from "../../stores/spaces/SpaceStore";
 | 
			
		||||
import { showThread } from '../../dispatcher/dispatch-actions/threads';
 | 
			
		||||
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 { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases';
 | 
			
		||||
import { ActionPayload } from "../../dispatcher/payloads";
 | 
			
		||||
@@ -154,7 +154,6 @@ export interface IRoomState {
 | 
			
		||||
    isInitialEventHighlighted?: boolean;
 | 
			
		||||
    replyToEvent?: MatrixEvent;
 | 
			
		||||
    numUnreadMessages: number;
 | 
			
		||||
    searching: boolean;
 | 
			
		||||
    searchTerm?: string;
 | 
			
		||||
    searchScope?: SearchScope;
 | 
			
		||||
    searchResults?: XOR<{}, ISearchResults>;
 | 
			
		||||
@@ -243,7 +242,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
			
		||||
            shouldPeek: true,
 | 
			
		||||
            membersLoaded: !llMembers,
 | 
			
		||||
            numUnreadMessages: 0,
 | 
			
		||||
            searching: false,
 | 
			
		||||
            searchResults: null,
 | 
			
		||||
            callState: null,
 | 
			
		||||
            guestsCanJoin: false,
 | 
			
		||||
@@ -898,14 +896,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
			
		||||
            case Action.ComposerInsert: {
 | 
			
		||||
                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
 | 
			
		||||
                    await this.onCancelSearchClick();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // re-dispatch to the correct composer
 | 
			
		||||
                dis.dispatch({
 | 
			
		||||
                    ...payload,
 | 
			
		||||
                dis.dispatch<ComposerInsertPayload>({
 | 
			
		||||
                    ...(payload as ComposerInsertPayload),
 | 
			
		||||
                    timelineRenderingType: TimelineRenderingType.Room,
 | 
			
		||||
                    composerType: this.state.editState ? ComposerType.Edit : ComposerType.Send,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
@@ -1349,7 +1350,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
			
		||||
 | 
			
		||||
        return searchPromise.then((results) => {
 | 
			
		||||
            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");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
@@ -1557,14 +1561,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
			
		||||
 | 
			
		||||
    private onSearchClick = () => {
 | 
			
		||||
        this.setState({
 | 
			
		||||
            searching: !this.state.searching,
 | 
			
		||||
            timelineRenderingType: this.state.timelineRenderingType === TimelineRenderingType.Search
 | 
			
		||||
                ? TimelineRenderingType.Room
 | 
			
		||||
                : TimelineRenderingType.Search,
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    private onCancelSearchClick = (): Promise<void> => {
 | 
			
		||||
        return new Promise<void>(resolve => {
 | 
			
		||||
            this.setState({
 | 
			
		||||
                searching: false,
 | 
			
		||||
                timelineRenderingType: TimelineRenderingType.Room,
 | 
			
		||||
                searchResults: null,
 | 
			
		||||
            }, resolve);
 | 
			
		||||
        });
 | 
			
		||||
@@ -1894,7 +1900,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
			
		||||
 | 
			
		||||
        let aux = null;
 | 
			
		||||
        let previewBar;
 | 
			
		||||
        if (this.state.searching) {
 | 
			
		||||
        if (this.state.timelineRenderingType === TimelineRenderingType.Search) {
 | 
			
		||||
            aux = <SearchBar
 | 
			
		||||
                searchInProgress={this.state.searchInProgress}
 | 
			
		||||
                onCancelClick={this.onCancelSearchClick}
 | 
			
		||||
 
 | 
			
		||||
@@ -322,8 +322,6 @@ interface IProps {
 | 
			
		||||
    // whether or not to display thread info
 | 
			
		||||
    showThreadInfo?: boolean;
 | 
			
		||||
 | 
			
		||||
    timelineRenderingType?: TimelineRenderingType;
 | 
			
		||||
 | 
			
		||||
    // if specified and `true`, the message his behing
 | 
			
		||||
    // hidden for moderation from other users but is
 | 
			
		||||
    // 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 {
 | 
			
		||||
        if (this.props.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
 | 
			
		||||
        if (this.context.timelineRenderingType === TimelineRenderingType.Search && this.props.mxEvent.threadRootId) {
 | 
			
		||||
            return (
 | 
			
		||||
                <p className="mx_ThreadSummaryIcon">{ _t("From a thread") }</p>
 | 
			
		||||
            );
 | 
			
		||||
@@ -986,11 +984,10 @@ export default class EventTile extends React.Component<IProps, IState> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private onSenderProfileClick = () => {
 | 
			
		||||
        if (!this.props.timelineRenderingType) return;
 | 
			
		||||
        dis.dispatch<ComposerInsertPayload>({
 | 
			
		||||
            action: Action.ComposerInsert,
 | 
			
		||||
            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(),
 | 
			
		||||
            highlighted: true,
 | 
			
		||||
            room_id: this.props.mxEvent.getRoomId(),
 | 
			
		||||
            metricsTrigger: this.props.timelineRenderingType === TimelineRenderingType.Search
 | 
			
		||||
            metricsTrigger: this.context.timelineRenderingType === TimelineRenderingType.Search
 | 
			
		||||
                ? "MessageSearch"
 | 
			
		||||
                : undefined,
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -122,7 +122,6 @@ export default class SearchResultTile extends React.Component<IProps> {
 | 
			
		||||
                        isTwelveHour={isTwelveHour}
 | 
			
		||||
                        alwaysShowTimestamps={alwaysShowTimestamps}
 | 
			
		||||
                        enableFlair={enableFlair}
 | 
			
		||||
                        timelineRenderingType={TimelineRenderingType.Search}
 | 
			
		||||
                        lastInSection={lastInSection}
 | 
			
		||||
                        continuation={continuation}
 | 
			
		||||
                        callEventGrouper={this.callEventGroupers.get(mxEv.getContent().call_id)}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,6 @@ const RoomContext = createContext<IRoomState>({
 | 
			
		||||
    shouldPeek: true,
 | 
			
		||||
    membersLoaded: false,
 | 
			
		||||
    numUnreadMessages: 0,
 | 
			
		||||
    searching: false,
 | 
			
		||||
    guestsCanJoin: false,
 | 
			
		||||
    canPeek: false,
 | 
			
		||||
    showApps: false,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user