Init states again after login to new account
This commit is contained in:
parent
4e47d679bc
commit
a5865825da
2 changed files with 26 additions and 1 deletions
|
@ -58,7 +58,7 @@ import {
|
||||||
import { getAccessToken } from './utils/auth';
|
import { getAccessToken } from './utils/auth';
|
||||||
import openCompose from './utils/open-compose';
|
import openCompose from './utils/open-compose';
|
||||||
import showToast from './utils/show-toast';
|
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 store from './utils/store';
|
||||||
import { getCurrentAccount } from './utils/store-utils';
|
import { getCurrentAccount } from './utils/store-utils';
|
||||||
import useInterval from './utils/useInterval';
|
import useInterval from './utils/useInterval';
|
||||||
|
@ -130,6 +130,7 @@ function App() {
|
||||||
initInstance(masto, instanceURL),
|
initInstance(masto, instanceURL),
|
||||||
initAccount(masto, instanceURL, accessToken),
|
initAccount(masto, instanceURL, accessToken),
|
||||||
]);
|
]);
|
||||||
|
initStates();
|
||||||
initPreferences(masto);
|
initPreferences(masto);
|
||||||
|
|
||||||
setIsLoggedIn(true);
|
setIsLoggedIn(true);
|
||||||
|
|
|
@ -60,6 +60,30 @@ const states = proxy({
|
||||||
|
|
||||||
export default states;
|
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) => {
|
subscribeKey(states, 'notificationsLast', (v) => {
|
||||||
console.log('CHANGE', v);
|
console.log('CHANGE', v);
|
||||||
store.account.set('notificationsLast', states.notificationsLast);
|
store.account.set('notificationsLast', states.notificationsLast);
|
||||||
|
|
Loading…
Add table
Reference in a new issue