diff --git a/src/app.jsx b/src/app.jsx index 0f491e94..16efbe2d 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -58,7 +58,7 @@ import { import { getAccessToken } from './utils/auth'; import openCompose from './utils/open-compose'; import showToast from './utils/show-toast'; -import states, { getStatus, saveStatus } from './utils/states'; +import states, { initStates, saveStatus } from './utils/states'; import store from './utils/store'; import { getCurrentAccount } from './utils/store-utils'; import useInterval from './utils/useInterval'; @@ -130,6 +130,7 @@ function App() { initInstance(masto, instanceURL), initAccount(masto, instanceURL, accessToken), ]); + initStates(); initPreferences(masto); setIsLoggedIn(true); diff --git a/src/utils/states.js b/src/utils/states.js index 6b8e281a..dde99563 100644 --- a/src/utils/states.js +++ b/src/utils/states.js @@ -60,6 +60,30 @@ const states = proxy({ export default states; +export function initStates() { + // init all account based states + // all keys that uses store.account.get() should be initialized here + states.notificationsLast = store.account.get('notificationsLast') || null; + states.shortcuts = store.account.get('shortcuts') ?? []; + states.settings.autoRefresh = + store.account.get('settings-autoRefresh') ?? false; + states.settings.shortcutsViewMode = + store.account.get('settings-shortcutsViewMode') ?? null; + states.settings.shortcutsColumnsMode = + store.account.get('settings-shortcutsColumnsMode') ?? false; + states.settings.boostsCarousel = + store.account.get('settings-boostsCarousel') ?? true; + states.settings.contentTranslation = + store.account.get('settings-contentTranslation') ?? true; + states.settings.contentTranslationTargetLanguage = + store.account.get('settings-contentTranslationTargetLanguage') || null; + states.settings.contentTranslationHideLanguages = + store.account.get('settings-contentTranslationHideLanguages') || []; + states.settings.contentTranslationAutoInline = + store.account.get('settings-contentTranslationAutoInline') ?? false; + states.settings.cloakMode = store.account.get('settings-cloakMode') ?? false; +} + subscribeKey(states, 'notificationsLast', (v) => { console.log('CHANGE', v); store.account.set('notificationsLast', states.notificationsLast);