mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
Fix load wrong account's stuff when adding new account
Some account-based calls were called before states are initialized
This commit is contained in:
parent
68759e64d1
commit
b8767f3618
3 changed files with 18 additions and 16 deletions
|
@ -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 () => {
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue