diff --git a/src/app.jsx b/src/app.jsx index 4f1acd06..ea7c1cc1 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -126,11 +126,13 @@ function App() { setUIState('default'); })(); } else { + window.__IGNORE_GET_ACCOUNT_ERROR__ = true; const account = getCurrentAccount(); if (account) { store.session.set('currentAccount', account.info.id); const { masto, instance } = api({ account }); console.log('masto', masto); + initStates(); initPreferences(masto); setUIState('loading'); (async () => { diff --git a/src/utils/states.js b/src/utils/states.js index 23b94ee7..b2424f00 100644 --- a/src/utils/states.js +++ b/src/utils/states.js @@ -18,7 +18,7 @@ const states = proxy({ homeLast: null, // Last item in 'home' list homeLastFetchTime: null, notifications: [], - notificationsLast: store.account.get('notificationsLast') || null, // Last read notification + notificationsLast: null, // Last read notification notificationsNew: [], notificationsShowNew: false, notificationsLastFetchTime: null, @@ -46,23 +46,18 @@ const states = proxy({ showGenericAccounts: false, showMediaAlt: false, // Shortcuts - shortcuts: store.account.get('shortcuts') ?? [], + shortcuts: [], // Settings settings: { - autoRefresh: store.account.get('settings-autoRefresh') ?? false, - shortcutsViewMode: store.account.get('settings-shortcutsViewMode') ?? null, - shortcutsColumnsMode: - store.account.get('settings-shortcutsColumnsMode') ?? false, - boostsCarousel: store.account.get('settings-boostsCarousel') ?? true, - contentTranslation: - store.account.get('settings-contentTranslation') ?? true, - contentTranslationTargetLanguage: - store.account.get('settings-contentTranslationTargetLanguage') || null, - contentTranslationHideLanguages: - store.account.get('settings-contentTranslationHideLanguages') || [], - contentTranslationAutoInline: - store.account.get('settings-contentTranslationAutoInline') ?? false, - cloakMode: store.account.get('settings-cloakMode') ?? false, + autoRefresh: false, + shortcutsViewMode: null, + shortcutsColumnsMode: false, + boostsCarousel: true, + contentTranslation: true, + contentTranslationTargetLanguage: null, + contentTranslationHideLanguages: [], + contentTranslationAutoInline: false, + cloakMode: false, }, }); diff --git a/src/utils/store-utils.js b/src/utils/store-utils.js index bd228392..6ea170b7 100644 --- a/src/utils/store-utils.js +++ b/src/utils/store-utils.js @@ -11,6 +11,11 @@ export function getAccountByAccessToken(accessToken) { } export function getCurrentAccount() { + if (!window.__IGNORE_GET_ACCOUNT_ERROR__) { + // Track down getCurrentAccount() calls before account-based states are initialized + console.error('getCurrentAccount() called before states are initialized'); + if (import.meta.env.DEV) console.trace(); + } const currentAccount = store.session.get('currentAccount'); const account = getAccount(currentAccount); return account;