Make Lifecycle.loadSession return an explicit result

- rather than inferring it from the fact it didn't call logging_in.
This commit is contained in:
Richard van der Hoff 2017-06-16 12:20:52 +01:00
parent 5f689b7929
commit db3d9c0573
2 changed files with 13 additions and 21 deletions

View file

@ -62,6 +62,8 @@ import { _t } from './languageHandler';
* true; defines the IS to use.
*
* @returns {Promise} a promise which resolves when the above process completes.
* Resolves to `true` if we ended up starting a session, or `false` if we
* failed.
*/
export function loadSession(opts) {
const fragmentQueryParams = opts.fragmentQueryParams || {};
@ -86,12 +88,12 @@ export function loadSession(opts) {
homeserverUrl: guestHsUrl,
identityServerUrl: guestIsUrl,
guest: true,
}, true);
}, true).then(() => true);
}
return _restoreFromLocalStorage().then((success) => {
if (success) {
return;
return true;
}
if (enableGuest) {
@ -99,6 +101,7 @@ export function loadSession(opts) {
}
// fall back to login screen
return false;
});
}
@ -176,9 +179,10 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) {
homeserverUrl: hsUrl,
identityServerUrl: isUrl,
guest: true,
}, true);
}, true).then(() => true);
}, (err) => {
console.error("Failed to register as guest: " + err + " " + err.data);
return false;
});
}