@@ -225,7 +225,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
225225 private firstSyncPromise : PromiseWithResolvers < void > ;
226226
227227 private screenAfterLogin ?: IScreen ;
228+
229+ /** True if we have successfully completed an OIDC or token login.
230+ *
231+ * XXX it's unclear if this is ever cleared, so what happens if the user logs out and then logs back in?
232+ */
228233 private tokenLogin ?: boolean ;
234+
229235 // What to focus on next component update, if anything
230236 private focusNext : FocusNextType ;
231237 private subTitleStatus : string ;
@@ -386,6 +392,26 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
386392 await Lifecycle . onSessionLockStolen ( ) ;
387393 }
388394
395+ /**
396+ * Perform actions that are specific to a user that has just logged in (compare {@link onLoggedIn}, which, despite
397+ * its name, is called when an already-logged-in client is restored at session startup).
398+ *
399+ * Called when:
400+ *
401+ * - We successfully completed an OIDC or token login, via {@link initSession}.
402+ * - The {@link Login} or {@link Register} components notify us that we successfully completed a non-OIDC login or
403+ * registration.
404+ *
405+ * In both cases, {@link Action.OnLoggedIn} will already have been emitted, but the call to {@link onLoggedIn} will
406+ * have been suppressed (by either {@link tokenLogin} being set, or the view being set to {@link Views.LOGIN} or
407+ * {@link Views.REGISTER}).
408+ *
409+ * {@link onWillStartClient} and {@link onClientStarted} will already have been called (but not necessarily
410+ * completed).
411+ *
412+ * This method either calls {@link onLiggedIn} directly, or switches to {@link Views.E2E_SETUP} or
413+ * {@link Views.COMPLETE_SECURITY}, which will later call {@link onCompleteSecurityE2eSetupFinished}.
414+ */
389415 private async postLoginSetup ( ) : Promise < void > {
390416 const cli = MatrixClientPeg . safeGet ( ) ;
391417 const cryptoEnabled = Boolean ( cli . getCrypto ( ) ) ;
@@ -1369,7 +1395,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13691395 }
13701396
13711397 /**
1372- * Called when a new logged in session has started
1398+ * Called when a new logged in session has started.
1399+ *
1400+ * Called:
1401+ *
1402+ * - on {@link Action.OnLoggedIn}, but only when we don't expect a separate call to {@link postLoginSetup}.
1403+ * - from {@link postLoginSetup}, when we don't have crypto setup tasks to perform after the login.
1404+ *
1405+ * It's never actually called if we have crypto setup tasks to perform after login (which we normally do, unless
1406+ * crypto is disabled.) XXX: is this a bug or a feature?
13731407 */
13741408 private async onLoggedIn ( ) : Promise < void > {
13751409 ThemeController . isLogin = false ;
@@ -1379,6 +1413,16 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13791413 await this . onShowPostLoginScreen ( ) ;
13801414 }
13811415
1416+ /**
1417+ * Show the first screen after the application is successfully loaded in a logged-in state.
1418+ *
1419+ * Called:
1420+ *
1421+ * - by {@link onLoggedIn}
1422+ * - by {@link onCompleteSecurityE2eSetupFinished}
1423+ *
1424+ * In other words, whenever we think we have completed the login and E2E setup tasks.
1425+ */
13821426 private async onShowPostLoginScreen ( ) : Promise < void > {
13831427 this . setStateForNewView ( { view : Views . LOGGED_IN } ) ;
13841428 // If a specific screen is set to be shown after login, show that above
@@ -2043,7 +2087,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
20432087 PerformanceMonitor . instance . stop ( PerformanceEntryNames . REGISTER ) ;
20442088 } ;
20452089
2046- // complete security / e2e setup has finished
2090+ /** Called when { @link Views.E2E_SETUP} or { @link Views.COMPLETE_SECURITY} have completed. */
20472091 private onCompleteSecurityE2eSetupFinished = async ( ) : Promise < void > => {
20482092 const forceVerify = await this . shouldForceVerification ( ) ;
20492093 if ( forceVerify ) {
0 commit comments