SUPPORT-9362: add attempts to read local storage

This commit is contained in:
gulnaz 2025-09-04 16:18:20 +03:00
parent 59ced43bbe
commit 6482fa184d

View file

@ -16,6 +16,8 @@ export interface UserSession {
@Injectable({providedIn: 'root'})
export class AuthorizationService implements OnDestroy {
private static READ_LS_ATTEMPTS: number = 50;
private session: UserSession;
public onSessionUpdate: Subject<UserSession> = new Subject<UserSession>();
@ -37,9 +39,7 @@ export class AuthorizationService implements OnDestroy {
if (parsedObj && parsedObj.traceId) {
if (parsedObj.className === 'update' || parsedObj.className === 'processError') {
parsedObj.appNumber = localStorage.getItem(parsedObj.traceId);
localStorage.removeItem(parsedObj.traceId);
this.statusUpdateService.update(parsedObj);
this.updateStatus(parsedObj, 0);
}
}
});
@ -48,6 +48,22 @@ export class AuthorizationService implements OnDestroy {
})
}
private updateStatus(parsedObj: any, count: number): void {
if (count === AuthorizationService.READ_LS_ATTEMPTS) {
return;
}
let appNumber = localStorage.getItem(parsedObj.traceId);
if (appNumber) {
parsedObj.appNumber = appNumber;
localStorage.removeItem(parsedObj.traceId);
this.statusUpdateService.update(parsedObj);
}
else {
setTimeout(() => this.updateStatus(parsedObj, count++), 100);
}
}
isAuthorized(): boolean {
return !!this.session;
}