bugfix 네트워크 절체시 발생하는 Alert 팝업 ngZone 으로 랩핑.

This commit is contained in:
leejinho 2020-03-25 09:23:56 +09:00
parent a2461ae2e6
commit 4d6c20bf9d
2 changed files with 44 additions and 39 deletions

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; import { Component, OnInit, OnDestroy, Inject, NgZone } from '@angular/core';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
@ -92,7 +92,8 @@ export class LoginPageComponent implements OnInit, OnDestroy {
private localStorageService: LocalStorageService, private localStorageService: LocalStorageService,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private externalApiService: ExternalApiService, private externalApiService: ExternalApiService,
private appAuthenticationService: AppAuthenticationService private appAuthenticationService: AppAuthenticationService,
private ngZone: NgZone
) { ) {
this.useRememberMe = this.useRememberMe =
environment.productConfig.authentication.rememberMe.use; environment.productConfig.authentication.rememberMe.use;
@ -317,6 +318,28 @@ export class LoginPageComponent implements OnInit, OnDestroy {
// Recursion function > onLogin // Recursion function > onLogin
this.onLogin(value); this.onLogin(value);
} else { } else {
this.ngZone.run(() => {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
width: '360px',
data: {
title: this.translateService.instant(
'accounts.errors.loginFailed'
),
html: this.translateService.instant(
'accounts.errors.networkFailedAndRetry'
)
}
});
this.loginBtnEnable = true;
});
}
}),
catchError(error => {
this.ngZone.run(() => {
this.dialogService.open< this.dialogService.open<
AlertDialogComponent, AlertDialogComponent,
AlertDialogData, AlertDialogData,
@ -333,26 +356,7 @@ export class LoginPageComponent implements OnInit, OnDestroy {
} }
}); });
this.loginBtnEnable = true; this.loginBtnEnable = true;
}
}),
catchError(error => {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
width: '360px',
data: {
title: this.translateService.instant(
'accounts.errors.loginFailed'
),
html: this.translateService.instant(
'accounts.errors.networkFailedAndRetry'
)
}
}); });
this.loginBtnEnable = true;
return of(); return of();
}) })
) )

View File

@ -138,7 +138,7 @@ export class Effects {
); );
} }
}), }),
catchError(async error => { catchError(error => {
if (!!selfParam.autoLogin) { if (!!selfParam.autoLogin) {
if (this.maxRetryCount > this.retryCount) { if (this.maxRetryCount > this.retryCount) {
this.store.dispatch(logoutInitialize()); this.store.dispatch(logoutInitialize());
@ -158,27 +158,28 @@ export class Effects {
); );
} }
} }
this.ngZone.run(async () => {
const result = await this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
width: '360px',
data: {
title: this.translateService.instant(
'accounts.errors.loginFailed'
),
html: this.translateService.instant(
'accounts.errors.networkFailedAndExit'
)
}
});
const result = await this.dialogService.open< if (!!result) {
AlertDialogComponent, this.nativeService.appExit();
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
width: '360px',
data: {
title: this.translateService.instant(
'accounts.errors.loginFailed'
),
html: this.translateService.instant(
'accounts.errors.networkFailedAndExit'
)
} }
}); });
if (!!result) {
this.nativeService.appExit();
}
console.log('not retry'); console.log('not retry');
return of(webLoginFailure({ error })); return of(webLoginFailure({ error }));
}) })