Remove underscores

pull/21833/head
J. Ryan Stinnett 2020-10-07 13:32:30 +01:00
parent 40292884bf
commit 72bd72e524
1 changed files with 23 additions and 23 deletions

View File

@ -107,7 +107,7 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
fragmentQueryParams.guest_access_token fragmentQueryParams.guest_access_token
) { ) {
console.log("Using guest access credentials"); console.log("Using guest access credentials");
return _doSetLoggedIn({ return doSetLoggedIn({
userId: fragmentQueryParams.guest_user_id, userId: fragmentQueryParams.guest_user_id,
accessToken: fragmentQueryParams.guest_access_token, accessToken: fragmentQueryParams.guest_access_token,
homeserverUrl: guestHsUrl, homeserverUrl: guestHsUrl,
@ -115,7 +115,7 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
guest: true, guest: true,
}, true).then(() => true); }, true).then(() => true);
} }
const success = await _restoreFromLocalStorage({ const success = await restoreFromLocalStorage({
ignoreGuest: Boolean(opts.ignoreGuest), ignoreGuest: Boolean(opts.ignoreGuest),
}); });
if (success) { if (success) {
@ -123,7 +123,7 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
} }
if (enableGuest) { if (enableGuest) {
return _registerAsGuest(guestHsUrl, guestIsUrl, defaultDeviceDisplayName); return registerAsGuest(guestHsUrl, guestIsUrl, defaultDeviceDisplayName);
} }
// fall back to welcome screen // fall back to welcome screen
@ -134,7 +134,7 @@ export async function loadSession(opts: ILoadSessionOpts = {}): Promise<boolean>
// need to show the general failure dialog. Instead, just go back to welcome. // need to show the general failure dialog. Instead, just go back to welcome.
return false; return false;
} }
return _handleLoadSessionFailure(e); return handleLoadSessionFailure(e);
} }
} }
@ -192,8 +192,8 @@ export function attemptTokenLogin(
}, },
).then(function(creds) { ).then(function(creds) {
console.log("Logged in with token"); console.log("Logged in with token");
return _clearStorage().then(() => { return clearStorage().then(() => {
_persistCredentialsToLocalStorage(creds); persistCredentialsToLocalStorage(creds);
// remember that we just logged in // remember that we just logged in
sessionStorage.setItem("mx_fresh_login", String(true)); sessionStorage.setItem("mx_fresh_login", String(true));
return true; return true;
@ -239,7 +239,7 @@ export function handleInvalidStoreError(e: InvalidStoreError): Promise<void> {
} }
} }
function _registerAsGuest( function registerAsGuest(
hsUrl: string, hsUrl: string,
isUrl: string, isUrl: string,
defaultDeviceDisplayName: string, defaultDeviceDisplayName: string,
@ -257,7 +257,7 @@ function _registerAsGuest(
}, },
}).then((creds) => { }).then((creds) => {
console.log(`Registered as guest: ${creds.user_id}`); console.log(`Registered as guest: ${creds.user_id}`);
return _doSetLoggedIn({ return doSetLoggedIn({
userId: creds.user_id, userId: creds.user_id,
deviceId: creds.device_id, deviceId: creds.device_id,
accessToken: creds.access_token, accessToken: creds.access_token,
@ -313,7 +313,7 @@ export function getLocalStorageSessionVars(): ILocalStorageSession {
// The plan is to gradually move the localStorage access done here into // The plan is to gradually move the localStorage access done here into
// SessionStore to avoid bugs where the view becomes out-of-sync with // SessionStore to avoid bugs where the view becomes out-of-sync with
// localStorage (e.g. isGuest etc.) // localStorage (e.g. isGuest etc.)
async function _restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promise<boolean> { async function restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promise<boolean> {
const ignoreGuest = opts?.ignoreGuest; const ignoreGuest = opts?.ignoreGuest;
if (!localStorage) { if (!localStorage) {
@ -339,7 +339,7 @@ async function _restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promi
sessionStorage.removeItem("mx_fresh_login"); sessionStorage.removeItem("mx_fresh_login");
console.log(`Restoring session for ${userId}`); console.log(`Restoring session for ${userId}`);
await _doSetLoggedIn({ await doSetLoggedIn({
userId: userId, userId: userId,
deviceId: deviceId, deviceId: deviceId,
accessToken: accessToken, accessToken: accessToken,
@ -356,7 +356,7 @@ async function _restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }): Promi
} }
} }
async function _handleLoadSessionFailure(e: Error): Promise<boolean> { async function handleLoadSessionFailure(e: Error): Promise<boolean> {
console.error("Unable to load session", e); console.error("Unable to load session", e);
const SessionRestoreErrorDialog = const SessionRestoreErrorDialog =
@ -369,7 +369,7 @@ async function _handleLoadSessionFailure(e: Error): Promise<boolean> {
const [success] = await modal.finished; const [success] = await modal.finished;
if (success) { if (success) {
// user clicked continue. // user clicked continue.
await _clearStorage(); await clearStorage();
return false; return false;
} }
@ -403,7 +403,7 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
console.log("Pickle key not created"); console.log("Pickle key not created");
} }
return _doSetLoggedIn(Object.assign({}, credentials, {pickleKey}), true); return doSetLoggedIn(Object.assign({}, credentials, {pickleKey}), true);
} }
/** /**
@ -434,7 +434,7 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
console.warn("Clearing all data: Old session belongs to a different user/session"); console.warn("Clearing all data: Old session belongs to a different user/session");
} }
return _doSetLoggedIn(credentials, overwrite); return doSetLoggedIn(credentials, overwrite);
} }
/** /**
@ -446,7 +446,7 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
* *
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started * @returns {Promise} promise which resolves to the new MatrixClient once it has been started
*/ */
async function _doSetLoggedIn( async function doSetLoggedIn(
credentials: IMatrixClientCreds, credentials: IMatrixClientCreds,
clearStorage: boolean, clearStorage: boolean,
): Promise<MatrixClient> { ): Promise<MatrixClient> {
@ -473,7 +473,7 @@ async function _doSetLoggedIn(
dis.dispatch({action: 'on_logging_in'}, true); dis.dispatch({action: 'on_logging_in'}, true);
if (clearStorage) { if (clearStorage) {
await _clearStorage(); await clearStorage();
} }
const results = await StorageManager.checkConsistency(); const results = await StorageManager.checkConsistency();
@ -481,9 +481,9 @@ async function _doSetLoggedIn(
// crypto store, we'll be generally confused when handling encrypted data. // crypto store, we'll be generally confused when handling encrypted data.
// Show a modal recommending a full reset of storage. // Show a modal recommending a full reset of storage.
if (results.dataInLocalStorage && results.cryptoInited && !results.dataInCryptoStore) { if (results.dataInLocalStorage && results.cryptoInited && !results.dataInCryptoStore) {
const signOut = await _showStorageEvictedDialog(); const signOut = await showStorageEvictedDialog();
if (signOut) { if (signOut) {
await _clearStorage(); await clearStorage();
// This error feels a bit clunky, but we want to make sure we don't go any // This error feels a bit clunky, but we want to make sure we don't go any
// further and instead head back to sign in. // further and instead head back to sign in.
throw new AbortLoginAndRebuildStorage( throw new AbortLoginAndRebuildStorage(
@ -511,7 +511,7 @@ async function _doSetLoggedIn(
if (localStorage) { if (localStorage) {
try { try {
_persistCredentialsToLocalStorage(credentials); persistCredentialsToLocalStorage(credentials);
// make sure we don't think that it's a fresh login any more // make sure we don't think that it's a fresh login any more
sessionStorage.removeItem("mx_fresh_login"); sessionStorage.removeItem("mx_fresh_login");
} catch (e) { } catch (e) {
@ -527,7 +527,7 @@ async function _doSetLoggedIn(
return client; return client;
} }
function _showStorageEvictedDialog(): Promise<boolean> { function showStorageEvictedDialog(): Promise<boolean> {
const StorageEvictedDialog = sdk.getComponent('views.dialogs.StorageEvictedDialog'); const StorageEvictedDialog = sdk.getComponent('views.dialogs.StorageEvictedDialog');
return new Promise(resolve => { return new Promise(resolve => {
Modal.createTrackedDialog('Storage evicted', '', StorageEvictedDialog, { Modal.createTrackedDialog('Storage evicted', '', StorageEvictedDialog, {
@ -540,7 +540,7 @@ function _showStorageEvictedDialog(): Promise<boolean> {
// `instanceof`. Babel 7 supports this natively in their class handling. // `instanceof`. Babel 7 supports this natively in their class handling.
class AbortLoginAndRebuildStorage extends Error { } class AbortLoginAndRebuildStorage extends Error { }
function _persistCredentialsToLocalStorage(credentials: IMatrixClientCreds): void { function persistCredentialsToLocalStorage(credentials: IMatrixClientCreds): void {
localStorage.setItem(HOMESERVER_URL_KEY, credentials.homeserverUrl); localStorage.setItem(HOMESERVER_URL_KEY, credentials.homeserverUrl);
if (credentials.identityServerUrl) { if (credentials.identityServerUrl) {
localStorage.setItem(ID_SERVER_URL_KEY, credentials.identityServerUrl); localStorage.setItem(ID_SERVER_URL_KEY, credentials.identityServerUrl);
@ -704,14 +704,14 @@ export async function onLoggedOut(): Promise<void> {
// that can occur when components try to use a null client. // that can occur when components try to use a null client.
dis.dispatch({action: 'on_logged_out'}, true); dis.dispatch({action: 'on_logged_out'}, true);
stopMatrixClient(); stopMatrixClient();
await _clearStorage({deleteEverything: true}); await clearStorage({deleteEverything: true});
} }
/** /**
* @param {object} opts Options for how to clear storage. * @param {object} opts Options for how to clear storage.
* @returns {Promise} promise which resolves once the stores have been cleared * @returns {Promise} promise which resolves once the stores have been cleared
*/ */
async function _clearStorage(opts?: { deleteEverything?: boolean }): Promise<void> { async function clearStorage(opts?: { deleteEverything?: boolean }): Promise<void> {
Analytics.disable(); Analytics.disable();
if (window.localStorage) { if (window.localStorage) {