SUPPORT-9362: add attempts to read local storage
This commit is contained in:
parent
59ced43bbe
commit
6482fa184d
1 changed files with 19 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue