@@ -935,22 +935,30 @@ export class OAuthService extends AuthConfig {
935935 ) ;
936936 }
937937
938+ // only run in Angular zone if it is 'changed' or 'error'
938939 switch ( e . data ) {
939940 case 'unchanged' :
940941 this . handleSessionUnchanged ( ) ;
941942 break ;
942943 case 'changed' :
943- this . handleSessionChange ( ) ;
944+ this . ngZone . run ( ( ) => {
945+ this . handleSessionChange ( )
946+ } ) ;
944947 break ;
945948 case 'error' :
946- this . handleSessionError ( ) ;
949+ this . ngZone . run ( ( ) => {
950+ this . handleSessionError ( )
951+ } ) ;
947952 break ;
948953 }
949954
950955 this . debug ( 'got info from session check inframe' , e ) ;
951956 } ;
952957
953- window . addEventListener ( 'message' , this . sessionCheckEventListener ) ;
958+ // prevent Angular from refreshing the view on every message (runs in intervals)
959+ this . ngZone . runOutsideAngular ( ( ) => {
960+ window . addEventListener ( 'message' , this . sessionCheckEventListener ) ;
961+ } ) ;
954962 }
955963
956964 private handleSessionUnchanged ( ) : void {
@@ -1029,10 +1037,12 @@ export class OAuthService extends AuthConfig {
10291037
10301038 private startSessionCheckTimer ( ) : void {
10311039 this . stopSessionCheckTimer ( ) ;
1032- this . sessionCheckTimer = setInterval (
1033- this . checkSession . bind ( this ) ,
1034- this . sessionCheckIntervall
1035- ) ;
1040+ this . ngZone . runOutsideAngular ( ( ) => {
1041+ this . sessionCheckTimer = setInterval (
1042+ this . checkSession . bind ( this ) ,
1043+ this . sessionCheckIntervall
1044+ ) ;
1045+ } ) ;
10361046 }
10371047
10381048 private stopSessionCheckTimer ( ) : void {
0 commit comments