fix: avoid flash target page show
This commit is contained in:
@ -17,6 +17,9 @@ export interface IAuthState {
|
||||
accounts: LocalAccount[];
|
||||
signInRequired: boolean;
|
||||
|
||||
hasAuthenticated: boolean;
|
||||
hasLoadedAccounts: boolean;
|
||||
|
||||
loadAccounts: () => Promise<void>;
|
||||
updateActiveAccount: (account: LocalAccount) => Promise<void>;
|
||||
authenticate: () => Promise<void>;
|
||||
@ -47,6 +50,9 @@ export const useAuth = create<IAuthState>((set, get) => ({
|
||||
loadingAccounts: false,
|
||||
signInRequired: false,
|
||||
|
||||
hasAuthenticated: false,
|
||||
hasLoadedAccounts: false,
|
||||
|
||||
updateActiveAccount: async (account) => {
|
||||
set({ activeAccount: account });
|
||||
|
||||
@ -82,7 +88,12 @@ export const useAuth = create<IAuthState>((set, get) => ({
|
||||
set({ signInRequired: true });
|
||||
}
|
||||
|
||||
set({ activeAccount: account, accounts, loadingAccounts: false });
|
||||
set({
|
||||
activeAccount: account,
|
||||
accounts,
|
||||
loadingAccounts: false,
|
||||
hasLoadedAccounts: true,
|
||||
});
|
||||
},
|
||||
|
||||
authenticate: async () => {
|
||||
@ -114,7 +125,7 @@ export const useAuth = create<IAuthState>((set, get) => ({
|
||||
// TODO: set error
|
||||
console.log(err);
|
||||
} finally {
|
||||
set({ authenticating: false });
|
||||
set({ authenticating: false, hasAuthenticated: true });
|
||||
}
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user