fix and update
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
buildAuthDevicePayload,
|
||||
IdentifyResponse,
|
||||
getApiErrorMessage,
|
||||
ensureApiGatewayReady,
|
||||
invalidateApiGatewayReady,
|
||||
isApiGatewayReady,
|
||||
isGatewayUnavailableError,
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
PinVerificationResponse,
|
||||
PublicUser,
|
||||
refreshAuthSession,
|
||||
resetGatewayCircuit,
|
||||
resetPinRequiredNotification,
|
||||
scheduleFedcmSessionSync,
|
||||
setPinRequiredHandler,
|
||||
@@ -200,6 +202,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
setIsApiReady(false);
|
||||
|
||||
try {
|
||||
await ensureApiGatewayReady();
|
||||
const session = await fetchAuthSession(accessToken);
|
||||
applySessionState(session, { setUser, setToken, activatePinLock, clearPinLock });
|
||||
initialBootstrapDoneRef.current = true;
|
||||
@@ -321,6 +324,14 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
try {
|
||||
for (let bootstrapAttempt = 0; bootstrapAttempt < 4; bootstrapAttempt += 1) {
|
||||
if (isInitialBootstrap) {
|
||||
try {
|
||||
await ensureApiGatewayReady(bootstrapAttempt > 0);
|
||||
} catch {
|
||||
// цикл bootstrap повторит после паузы
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (currentToken) {
|
||||
setToken(currentToken);
|
||||
@@ -375,6 +386,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
} catch (error) {
|
||||
if (isGatewayUnavailableError(error) && isInitialBootstrap && bootstrapAttempt + 1 < 4) {
|
||||
invalidateApiGatewayReady();
|
||||
resetGatewayCircuit();
|
||||
setBootstrapError(
|
||||
'Не удалось подключиться к серверу API (502). Подождите несколько секунд и нажмите «Повторить».'
|
||||
);
|
||||
@@ -697,7 +709,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
isLoading,
|
||||
isApiReady,
|
||||
isSessionReady,
|
||||
isContentReady: isSessionReady,
|
||||
isContentReady: isSessionReady && isApiReady,
|
||||
isPinLocked,
|
||||
hasStoredSession,
|
||||
login,
|
||||
@@ -723,6 +735,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
setBootstrapError(null);
|
||||
initialBootstrapDoneRef.current = false;
|
||||
invalidateApiGatewayReady();
|
||||
resetGatewayCircuit();
|
||||
setIsLoading(true);
|
||||
setIsApiReady(false);
|
||||
setIsSessionReady(false);
|
||||
|
||||
Reference in New Issue
Block a user