diff --git a/src/app.jsx b/src/app.jsx index 2e8f99f0..f02855b3 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -48,6 +48,8 @@ import Trending from './pages/trending'; import Welcome from './pages/welcome'; import { api, + hasInstance, + hasPreferences, initAccount, initClient, initInstance, @@ -410,10 +412,16 @@ function App() { setUIState('loading'); (async () => { try { - await Promise.allSettled([ - initPreferences(client), - initInstance(client, instance), - ]); + if (hasPreferences() && hasInstance(instance)) { + // Non-blocking + initPreferences(client); + initInstance(client, instance); + } else { + await Promise.allSettled([ + initPreferences(client), + initInstance(client, instance), + ]); + } } catch (e) { } finally { setIsLoggedIn(true); diff --git a/src/utils/api.js b/src/utils/api.js index d09d00e8..cf6652bc 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -57,6 +57,11 @@ export function initClient({ instance, accessToken }) { return client; } +export function hasInstance(instance) { + const instances = store.local.getJSON('instances') || {}; + return !!instances[instance]; +} + // Get the instance information // The config is needed for composing export async function initInstance(client, instance) { @@ -132,6 +137,10 @@ export async function initAccount(client, instance, accessToken, vapidKey) { }); } +export function hasPreferences() { + return !!store.account.get('preferences'); +} + // Get preferences export async function initPreferences(client) { try {