pl-fe: fix the settings_store error
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
190fca998e
commit
7ca17884f8
1 changed files with 14 additions and 13 deletions
|
@ -261,17 +261,19 @@ const importMastodonPreload = (state: State, data: ImmutableMap<string, any>) =>
|
||||||
});
|
});
|
||||||
|
|
||||||
const persistAuthAccount = (account: CredentialAccount) => {
|
const persistAuthAccount = (account: CredentialAccount) => {
|
||||||
if (account && account.url) {
|
const persistedAccount = { ...account };
|
||||||
const key = `authAccount:${account.url}`;
|
const key = `authAccount:${account.url}`;
|
||||||
KVStore.getItem(key).then((oldAccount: any) => {
|
|
||||||
const settings = oldAccount?.settings_store || {};
|
KVStore.getItem(key).then((oldAccount: any) => {
|
||||||
if (!account.settings_store) {
|
const settings = oldAccount?.settings_store || {};
|
||||||
account.settings_store = settings;
|
if (!persistedAccount.settings_store) {
|
||||||
}
|
persistedAccount.settings_store = settings;
|
||||||
KVStore.setItem(key, account);
|
}
|
||||||
})
|
KVStore.setItem(key, persistedAccount);
|
||||||
.catch(console.error);
|
})
|
||||||
}
|
.catch(console.error);
|
||||||
|
|
||||||
|
return persistedAccount;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteForbiddenToken = (state: State, error: { response: PlfeResponse }, token: string) => {
|
const deleteForbiddenToken = (state: State, error: { response: PlfeResponse }, token: string) => {
|
||||||
|
@ -293,8 +295,7 @@ const reducer = (state: State, action: AnyAction | AuthAction | MeAction | Prelo
|
||||||
case AUTH_LOGGED_OUT:
|
case AUTH_LOGGED_OUT:
|
||||||
return deleteUser(state, action.account);
|
return deleteUser(state, action.account);
|
||||||
case VERIFY_CREDENTIALS_SUCCESS:
|
case VERIFY_CREDENTIALS_SUCCESS:
|
||||||
persistAuthAccount(action.account);
|
return importCredentials(state, action.token, persistAuthAccount(action.account));
|
||||||
return importCredentials(state, action.token, action.account);
|
|
||||||
case VERIFY_CREDENTIALS_FAIL:
|
case VERIFY_CREDENTIALS_FAIL:
|
||||||
return deleteForbiddenToken(state, action.error, action.token);
|
return deleteForbiddenToken(state, action.error, action.token);
|
||||||
case SWITCH_ACCOUNT:
|
case SWITCH_ACCOUNT:
|
||||||
|
|
Loading…
Reference in a new issue