Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,22 +935,30 @@ export class OAuthService extends AuthConfig {
);
}

// only run in Angular zone if it is 'changed' or 'error'
switch (e.data) {
case 'unchanged':
this.handleSessionUnchanged();
break;
case 'changed':
this.handleSessionChange();
this.ngZone.run(() => {
this.handleSessionChange()
});
break;
case 'error':
this.handleSessionError();
this.ngZone.run(() => {
this.handleSessionError()
});
break;
}

this.debug('got info from session check inframe', e);
};

window.addEventListener('message', this.sessionCheckEventListener);
// prevent Angular from refreshing the view on every message (runs in intervals)
this.ngZone.runOutsideAngular(() => {
window.addEventListener('message', this.sessionCheckEventListener);
});
}

private handleSessionUnchanged(): void {
Expand Down Expand Up @@ -1029,10 +1037,12 @@ export class OAuthService extends AuthConfig {

private startSessionCheckTimer(): void {
this.stopSessionCheckTimer();
this.sessionCheckTimer = setInterval(
this.checkSession.bind(this),
this.sessionCheckIntervall
);
this.ngZone.runOutsideAngular(() => {
this.sessionCheckTimer = setInterval(
this.checkSession.bind(this),
this.sessionCheckIntervall
);
});
}

private stopSessionCheckTimer(): void {
Expand Down