UNPKG

matrix-react-sdk

Version:
179 lines (178 loc) 5.97 kB
import React from "react"; import { QueryDict } from "matrix-js-sdk/src/utils"; import "what-input"; import { ConfigOptions } from "../../SdkConfig"; import "../../stores/LifecycleStore"; import "../../stores/AutoRageshakeStore"; import PageType from "../../PageTypes"; import { IOpts } from "../../createRoom"; import ResizeNotifier from "../../utils/ResizeNotifier"; import { IThreepidInvite } from "../../stores/ThreepidInviteStore"; import Views from "../../Views"; import { ValidatedServerConfig } from "../../utils/ValidatedServerConfig"; export { default as Views } from "../../Views"; interface IScreen { screen: string; params?: QueryDict; } interface IProps { config: ConfigOptions; onNewScreen: (screen: string, replaceLast: boolean) => void; enableGuest?: boolean; realQueryParams: QueryDict; startingFragmentQueryParams?: QueryDict; onTokenLoginCompleted: () => void; initialScreenAfterLogin?: IScreen; defaultDeviceDisplayName?: string; initPromiseCallback?: (p: Promise<void>) => void; } interface IState { view: Views; page_type?: PageType; currentRoomId: string | null; currentUserId: string | null; collapseLhs: boolean; register_client_secret?: string; register_session_id?: string; register_id_sid?: string; isMobileRegistration?: boolean; hideToSRUsers: boolean; syncError: Error | null; resizeNotifier: ResizeNotifier; serverConfig?: ValidatedServerConfig; ready: boolean; threepidInvite?: IThreepidInvite; roomOobData?: object; pendingInitialSync?: boolean; justRegistered?: boolean; roomJustCreatedOpts?: IOpts; forceTimeline?: boolean; } export default class MatrixChat extends React.PureComponent<IProps, IState> { static displayName: string; static defaultProps: { realQueryParams: {}; startingFragmentQueryParams: {}; config: {}; onTokenLoginCompleted: () => void; }; private firstSyncComplete; private firstSyncPromise; private screenAfterLogin?; private tokenLogin?; private focusNext; private subTitleStatus; private prevWindowWidth; private voiceBroadcastResumer?; private readonly loggedInView; private readonly dispatcherRef; private readonly themeWatcher; private readonly fontWatcher; private readonly stores; constructor(props: IProps); /** * Kick off a call to {@link initSession}, and handle any errors */ private startInitSession; /** * Do what we can to establish a Matrix session. * * * Special-case soft-logged-out sessions * * If we have OIDC or token login parameters, follow them * * If we have a guest access token in the query params, use that * * If we have parameters in local storage, use them * * Attempt to auto-register as a guest * * If all else fails, present a login screen. */ private initSession; private onSessionLockStolen; private postLoginSetup; setState<K extends keyof IState>(state: ((prevState: Readonly<IState>, props: Readonly<IProps>) => Pick<IState, K> | IState | null) | (Pick<IState, K> | IState | null), callback?: () => void): void; componentDidMount(): void; componentDidUpdate(prevProps: IProps, prevState: IState): void; componentWillUnmount(): void; private onWindowResized; private warnInConsole; private getFallbackHsUrl; private getServerProperties; private loadSession; private startPageChangeTimer; private stopPageChangeTimer; private shouldTrackPageChange; private setStateForNewView; private onAction; private setPage; private startRegistration; private viewRoom; private viewSomethingBehindModal; private viewWelcome; private viewLogin; private viewHome; private viewUser; private createRoom; private chatCreateOrReuse; private leaveRoomWarnings; private leaveRoom; private forgetRoom; private copyRoom; /** * Returns true if the user must go through the device verification process before they * can use the app. * @returns true if the user must verify */ private shouldForceVerification; /** * Called when a new logged in session has started */ private onLoggedIn; private onShowPostLoginScreen; private initPosthogAnalyticsToast; private showScreenAfterLogin; private viewLastRoom; /** * Called when the session is logged out */ private onLoggedOut; /** * Called when the session is softly logged out */ private onSoftLogout; /** * Called just before the matrix client is started * (useful for setting listeners) */ private onWillStartClient; /** * Called shortly after the matrix client has started. Useful for * setting up anything that requires the client to be started. * @private */ private onClientStarted; showScreen(screen: string, params?: { [key: string]: any; }): void; private notifyNewScreen; private onLogoutClick; private handleResize; private dispatchTimelineResize; private onRegisterClick; private onLoginClick; private onForgotPasswordClick; private onRegisterFlowComplete; private onRegistered; private onSendEvent; private setPageSubtitle; private onUpdateStatusIndicator; private onServerConfigChange; /** * After registration or login, we run various post-auth steps before entering the app * proper, such setting up cross-signing or verifying the new session. * * Note: SSO users (and any others using token login) currently do not pass through * this, as they instead jump straight into the app after `attemptTokenLogin`. */ private onUserCompletedLoginFlow; private onCompleteSecurityE2eSetupFinished; private getFragmentAfterLogin; render(): React.ReactNode; }