nicolium: hack for fixing broken login, will refactor and clean this up soon

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-02 22:42:30 +01:00
parent 249d6c84ac
commit dda8d05d3a
4 changed files with 13 additions and 10 deletions

View File

@ -288,13 +288,15 @@ interface SwitchAccountAction {
account: Account;
}
const switchAccount = (accountId: string) => (dispatch: AppDispatch) => {
const switchAccount = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => {
const account = selectAccount(accountId);
if (!account) return;
// Clear all stored cache from React Query
queryClient.invalidateQueries();
queryClient.clear();
if (typeof getState().me === 'string' && getState().me !== account.id) {
// Clear all stored cache from React Query
queryClient.invalidateQueries();
queryClient.clear();
}
return dispatch<SwitchAccountAction>({ type: SWITCH_ACCOUNT, account });
};

View File

@ -48,9 +48,8 @@ const SignUpPanel = () => {
return account;
})
.then((account: { id: string }) => {
if (typeof me === 'string') {
dispatch(switchAccount(account.id));
} else {
dispatch(switchAccount(account.id));
if (typeof me !== 'string') {
setShouldRedirect(true);
}
})

View File

@ -47,9 +47,8 @@ const LoginPage = () => {
})
.then((account: { id: string }) => {
closeModal();
if (typeof me === 'string') {
dispatch(switchAccount(account.id));
} else {
dispatch(switchAccount(account.id));
if (typeof me !== 'string') {
setShouldRedirect(true);
}
})

View File

@ -3,6 +3,7 @@ import {
AUTH_ACCOUNT_REMEMBER_SUCCESS,
VERIFY_CREDENTIALS_SUCCESS,
type AuthAction,
SWITCH_ACCOUNT,
} from '@/actions/auth';
import {
ME_FETCH_SUCCESS,
@ -38,6 +39,8 @@ const me = (state: Me = initialState, action: AuthAction | MeAction): Me => {
return false;
case ME_FETCH_FAIL:
return handleForbidden(state, action.error as any);
case SWITCH_ACCOUNT:
return action.account.id;
default:
return state;
}