fix and update
This commit is contained in:
@@ -40,6 +40,8 @@ interface AuthContextValue {
|
||||
token: string | null;
|
||||
isLoading: boolean;
|
||||
isApiReady: boolean;
|
||||
/** false первые ~600 ms после bootstrap — блокирует шторм API сразу после логина */
|
||||
isContentReady: boolean;
|
||||
isPinLocked: boolean;
|
||||
hasStoredSession: boolean;
|
||||
login: (login: string, password: string) => Promise<AuthTokens>;
|
||||
@@ -109,6 +111,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const [user, setUser] = React.useState<PublicUser | null>(null);
|
||||
const [isLoading, setIsLoading] = React.useState(true);
|
||||
const [isApiReady, setIsApiReady] = React.useState(false);
|
||||
const [isContentReady, setIsContentReady] = React.useState(false);
|
||||
const [isPinLocked, setIsPinLocked] = React.useState(false);
|
||||
const [hasStoredSession, setHasStoredSession] = React.useState(false);
|
||||
const [lockedSessionId, setLockedSessionId] = React.useState<string | null>(null);
|
||||
@@ -177,8 +180,9 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
initialBootstrapDoneRef.current = true;
|
||||
setIsApiReady(true);
|
||||
setIsLoading(false);
|
||||
setIsContentReady(false);
|
||||
if (auth.pinVerified !== false) {
|
||||
scheduleFedcmSessionSync(auth.accessToken, 2000);
|
||||
scheduleFedcmSessionSync(auth.accessToken, 2500);
|
||||
}
|
||||
},
|
||||
[clearPinLock]
|
||||
@@ -546,6 +550,21 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
Boolean(hasStoredSession || token || user) &&
|
||||
(isLoading || !isApiReady);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isBootstrapping) {
|
||||
setIsContentReady(false);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
const timer = window.setTimeout(() => {
|
||||
if (!cancelled) setIsContentReady(true);
|
||||
}, 650);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.clearTimeout(timer);
|
||||
};
|
||||
}, [isBootstrapping]);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider
|
||||
value={{
|
||||
@@ -553,6 +572,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
token,
|
||||
isLoading,
|
||||
isApiReady,
|
||||
isContentReady,
|
||||
isPinLocked,
|
||||
hasStoredSession,
|
||||
login,
|
||||
@@ -570,7 +590,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
logout
|
||||
}}
|
||||
>
|
||||
{isBootstrapping ? <AppBootstrapScreen /> : children}
|
||||
{isBootstrapping || !isContentReady ? <AppBootstrapScreen /> : children}
|
||||
<PinLockModal open={isPinLocked} isSubmitting={pinSubmitting} error={pinError} onSubmit={handlePinUnlock} />
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user