@@ -202,7 +202,10 @@ interface IState {
202202 hideToSRUsers : boolean ;
203203 syncError : Error | null ;
204204 serverConfig ?: ValidatedServerConfig ;
205+
206+ /** Has our MatrixClient started? */
205207 ready : boolean ;
208+
206209 threepidInvite ?: IThreepidInvite ;
207210 roomOobData ?: object ;
208211 pendingInitialSync ?: boolean ;
@@ -225,7 +228,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
225228 private firstSyncPromise : PromiseWithResolvers < void > ;
226229
227230 private screenAfterLogin ?: IScreen ;
231+
232+ /** True if we have successfully completed an OIDC or token login.
233+ *
234+ * XXX it's unclear if this is ever cleared, so what happens if the user logs out and then logs back in?
235+ */
228236 private tokenLogin ?: boolean ;
237+
229238 // What to focus on next component update, if anything
230239 private focusNext : FocusNextType ;
231240 private subTitleStatus : string ;
@@ -386,6 +395,26 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
386395 await Lifecycle . onSessionLockStolen ( ) ;
387396 }
388397
398+ /**
399+ * Perform actions that are specific to a user that has just logged in (compare {@link onLoggedIn}, which, despite
400+ * its name, is called when an already-logged-in client is restored at session startup).
401+ *
402+ * Called when:
403+ *
404+ * - We successfully completed an OIDC or token login, via {@link initSession}.
405+ * - The {@link Login} or {@link Register} components notify us that we successfully completed a non-OIDC login or
406+ * registration.
407+ *
408+ * In both cases, {@link Action.OnLoggedIn} will already have been emitted, but the call to {@link onLoggedIn} will
409+ * have been suppressed (by either {@link tokenLogin} being set, or the view being set to {@link Views.LOGIN} or
410+ * {@link Views.REGISTER}).
411+ *
412+ * {@link onWillStartClient} and {@link onClientStarted} will already have been called (but not necessarily
413+ * completed).
414+ *
415+ * This method either calls {@link onLiggedIn} directly, or switches to {@link Views.E2E_SETUP} or
416+ * {@link Views.COMPLETE_SECURITY}, which will later call {@link onCompleteSecurityE2eSetupFinished}.
417+ */
389418 private async postLoginSetup ( ) : Promise < void > {
390419 const cli = MatrixClientPeg . safeGet ( ) ;
391420 const cryptoEnabled = Boolean ( cli . getCrypto ( ) ) ;
@@ -1369,7 +1398,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13691398 }
13701399
13711400 /**
1372- * Called when a new logged in session has started
1401+ * Called when a new logged in session has started.
1402+ *
1403+ * Called:
1404+ *
1405+ * - on {@link Action.OnLoggedIn}, but only when we don't expect a separate call to {@link postLoginSetup}.
1406+ * - from {@link postLoginSetup}, when we don't have crypto setup tasks to perform after the login.
1407+ *
1408+ * It's never actually called if we have crypto setup tasks to perform after login (which we normally do, unless
1409+ * crypto is disabled.) XXX: is this a bug or a feature?
13731410 */
13741411 private async onLoggedIn ( ) : Promise < void > {
13751412 ThemeController . isLogin = false ;
@@ -1379,6 +1416,16 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13791416 await this . onShowPostLoginScreen ( ) ;
13801417 }
13811418
1419+ /**
1420+ * Show the first screen after the application is successfully loaded in a logged-in state.
1421+ *
1422+ * Called:
1423+ *
1424+ * - by {@link onLoggedIn}
1425+ * - by {@link onCompleteSecurityE2eSetupFinished}
1426+ *
1427+ * In other words, whenever we think we have completed the login and E2E setup tasks.
1428+ */
13821429 private async onShowPostLoginScreen ( ) : Promise < void > {
13831430 this . setStateForNewView ( { view : Views . LOGGED_IN } ) ;
13841431 // If a specific screen is set to be shown after login, show that above
@@ -2043,7 +2090,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
20432090 PerformanceMonitor . instance . stop ( PerformanceEntryNames . REGISTER ) ;
20442091 } ;
20452092
2046- // complete security / e2e setup has finished
2093+ /** Called when { @link Views.E2E_SETUP} or { @link Views.COMPLETE_SECURITY} have completed. */
20472094 private onCompleteSecurityE2eSetupFinished = async ( ) : Promise < void > => {
20482095 const forceVerify = await this . shouldForceVerification ( ) ;
20492096 if ( forceVerify ) {
0 commit comments