@@ -107,23 +107,23 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
107107 fragmentQueryParams . guest_access_token
108108 ) {
109109 console . log ( "Using guest access credentials" ) ;
110- return _doSetLoggedIn ( {
110+ return doSetLoggedIn ( {
111111 userId : fragmentQueryParams . guest_user_id ,
112112 accessToken : fragmentQueryParams . guest_access_token ,
113113 homeserverUrl : guestHsUrl ,
114114 identityServerUrl : guestIsUrl ,
115115 guest : true ,
116116 } , true ) . then ( ( ) => true ) ;
117117 }
118- const success = await _restoreFromLocalStorage ( {
118+ const success = await restoreFromLocalStorage ( {
119119 ignoreGuest : Boolean ( opts . ignoreGuest ) ,
120120 } ) ;
121121 if ( success ) {
122122 return true ;
123123 }
124124
125125 if ( enableGuest ) {
126- return _registerAsGuest ( guestHsUrl , guestIsUrl , defaultDeviceDisplayName ) ;
126+ return registerAsGuest ( guestHsUrl , guestIsUrl , defaultDeviceDisplayName ) ;
127127 }
128128
129129 // fall back to welcome screen
@@ -134,7 +134,7 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
134134 // need to show the general failure dialog. Instead, just go back to welcome.
135135 return false ;
136136 }
137- return _handleLoadSessionFailure ( e ) ;
137+ return handleLoadSessionFailure ( e ) ;
138138 }
139139}
140140
@@ -192,8 +192,8 @@ export function attemptTokenLogin(
192192 } ,
193193 ) . then ( function ( creds ) {
194194 console . log ( "Logged in with token" ) ;
195- return _clearStorage ( ) . then ( ( ) => {
196- _persistCredentialsToLocalStorage ( creds ) ;
195+ return clearStorage ( ) . then ( ( ) => {
196+ persistCredentialsToLocalStorage ( creds ) ;
197197 // remember that we just logged in
198198 sessionStorage . setItem ( "mx_fresh_login" , String ( true ) ) ;
199199 return true ;
@@ -239,7 +239,7 @@ export function handleInvalidStoreError(e: InvalidStoreError): Promise<void> {
239239 }
240240}
241241
242- function _registerAsGuest (
242+ function registerAsGuest (
243243 hsUrl : string ,
244244 isUrl : string ,
245245 defaultDeviceDisplayName : string ,
@@ -257,7 +257,7 @@ function _registerAsGuest(
257257 } ,
258258 } ) . then ( ( creds ) => {
259259 console . log ( `Registered as guest: ${ creds . user_id } ` ) ;
260- return _doSetLoggedIn ( {
260+ return doSetLoggedIn ( {
261261 userId : creds . user_id ,
262262 deviceId : creds . device_id ,
263263 accessToken : creds . access_token ,
@@ -313,7 +313,7 @@ export function getLocalStorageSessionVars(): ILocalStorageSession {
313313// The plan is to gradually move the localStorage access done here into
314314// SessionStore to avoid bugs where the view becomes out-of-sync with
315315// localStorage (e.g. isGuest etc.)
316- async function _restoreFromLocalStorage ( opts ?: { ignoreGuest ?: boolean } ) : Promise < boolean > {
316+ async function restoreFromLocalStorage ( opts ?: { ignoreGuest ?: boolean } ) : Promise < boolean > {
317317 const ignoreGuest = opts ?. ignoreGuest ;
318318
319319 if ( ! localStorage ) {
@@ -339,7 +339,7 @@ async function _restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promi
339339 sessionStorage . removeItem ( "mx_fresh_login" ) ;
340340
341341 console . log ( `Restoring session for ${ userId } ` ) ;
342- await _doSetLoggedIn ( {
342+ await doSetLoggedIn ( {
343343 userId : userId ,
344344 deviceId : deviceId ,
345345 accessToken : accessToken ,
@@ -356,7 +356,7 @@ async function _restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promi
356356 }
357357}
358358
359- async function _handleLoadSessionFailure ( e : Error ) : Promise < boolean > {
359+ async function handleLoadSessionFailure ( e : Error ) : Promise < boolean > {
360360 console . error ( "Unable to load session" , e ) ;
361361
362362 const SessionRestoreErrorDialog =
@@ -369,7 +369,7 @@ async function _handleLoadSessionFailure(e: Error): Promise<boolean> {
369369 const [ success ] = await modal . finished ;
370370 if ( success ) {
371371 // user clicked continue.
372- await _clearStorage ( ) ;
372+ await clearStorage ( ) ;
373373 return false ;
374374 }
375375
@@ -403,7 +403,7 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
403403 console . log ( "Pickle key not created" ) ;
404404 }
405405
406- return _doSetLoggedIn ( Object . assign ( { } , credentials , { pickleKey} ) , true ) ;
406+ return doSetLoggedIn ( Object . assign ( { } , credentials , { pickleKey} ) , true ) ;
407407}
408408
409409/**
@@ -434,7 +434,7 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
434434 console . warn ( "Clearing all data: Old session belongs to a different user/session" ) ;
435435 }
436436
437- return _doSetLoggedIn ( credentials , overwrite ) ;
437+ return doSetLoggedIn ( credentials , overwrite ) ;
438438}
439439
440440/**
@@ -446,7 +446,7 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
446446 *
447447 * @returns {Promise } promise which resolves to the new MatrixClient once it has been started
448448 */
449- async function _doSetLoggedIn (
449+ async function doSetLoggedIn (
450450 credentials : IMatrixClientCreds ,
451451 clearStorage : boolean ,
452452) : Promise < MatrixClient > {
@@ -473,17 +473,17 @@ async function _doSetLoggedIn(
473473 dis . dispatch ( { action : 'on_logging_in' } , true ) ;
474474
475475 if ( clearStorage ) {
476- await _clearStorage ( ) ;
476+ await clearStorage ( ) ;
477477 }
478478
479479 const results = await StorageManager . checkConsistency ( ) ;
480480 // If there's an inconsistency between account data in local storage and the
481481 // crypto store, we'll be generally confused when handling encrypted data.
482482 // Show a modal recommending a full reset of storage.
483483 if ( results . dataInLocalStorage && results . cryptoInited && ! results . dataInCryptoStore ) {
484- const signOut = await _showStorageEvictedDialog ( ) ;
484+ const signOut = await showStorageEvictedDialog ( ) ;
485485 if ( signOut ) {
486- await _clearStorage ( ) ;
486+ await clearStorage ( ) ;
487487 // This error feels a bit clunky, but we want to make sure we don't go any
488488 // further and instead head back to sign in.
489489 throw new AbortLoginAndRebuildStorage (
@@ -511,7 +511,7 @@ async function _doSetLoggedIn(
511511
512512 if ( localStorage ) {
513513 try {
514- _persistCredentialsToLocalStorage ( credentials ) ;
514+ persistCredentialsToLocalStorage ( credentials ) ;
515515 // make sure we don't think that it's a fresh login any more
516516 sessionStorage . removeItem ( "mx_fresh_login" ) ;
517517 } catch ( e ) {
@@ -527,7 +527,7 @@ async function _doSetLoggedIn(
527527 return client ;
528528}
529529
530- function _showStorageEvictedDialog ( ) : Promise < boolean > {
530+ function showStorageEvictedDialog ( ) : Promise < boolean > {
531531 const StorageEvictedDialog = sdk . getComponent ( 'views.dialogs.StorageEvictedDialog' ) ;
532532 return new Promise ( resolve => {
533533 Modal . createTrackedDialog ( 'Storage evicted' , '' , StorageEvictedDialog , {
@@ -540,7 +540,7 @@ function _showStorageEvictedDialog(): Promise<boolean> {
540540// `instanceof`. Babel 7 supports this natively in their class handling.
541541class AbortLoginAndRebuildStorage extends Error { }
542542
543- function _persistCredentialsToLocalStorage ( credentials : IMatrixClientCreds ) : void {
543+ function persistCredentialsToLocalStorage ( credentials : IMatrixClientCreds ) : void {
544544 localStorage . setItem ( HOMESERVER_URL_KEY , credentials . homeserverUrl ) ;
545545 if ( credentials . identityServerUrl ) {
546546 localStorage . setItem ( ID_SERVER_URL_KEY , credentials . identityServerUrl ) ;
@@ -704,14 +704,14 @@ export async function onLoggedOut(): Promise<void> {
704704 // that can occur when components try to use a null client.
705705 dis . dispatch ( { action : 'on_logged_out' } , true ) ;
706706 stopMatrixClient ( ) ;
707- await _clearStorage ( { deleteEverything : true } ) ;
707+ await clearStorage ( { deleteEverything : true } ) ;
708708}
709709
710710/**
711711 * @param {object } opts Options for how to clear storage.
712712 * @returns {Promise } promise which resolves once the stores have been cleared
713713 */
714- async function _clearStorage ( opts ?: { deleteEverything ?: boolean } ) : Promise < void > {
714+ async function clearStorage ( opts ?: { deleteEverything ?: boolean } ) : Promise < void > {
715715 Analytics . disable ( ) ;
716716
717717 if ( window . localStorage ) {
0 commit comments