diff --git a/src/app/app.utils.ts b/src/app/app.utils.ts index 36f18381..13a240b3 100644 --- a/src/app/app.utils.ts +++ b/src/app/app.utils.ts @@ -14,6 +14,8 @@ import { Directory, Filesystem } from '@capacitor/filesystem'; import { Toast } from '@capacitor/toast'; import { sha256 } from 'js-sha256'; import { MatTableDataSource } from '@angular/material/table'; +import { App } from '@capacitor/app'; +import { environment } from 'src/environments/environment'; export default class Utils { static getCurrentDate() { let now = new Date(); @@ -1038,4 +1040,25 @@ export default class Utils { dataSource.paginator.firstPage(); } } + + static androidAppExit(resourceBundleJson: any, dialog: MatDialog) { + const isAndroidAppMode = environment.isAndroidAppMode == 'yes' ? true : false; + if (isAndroidAppMode) { + let resourceBundle = resourceBundleJson.dialogMessages; + let successMsg = 'success'; + let logoutMsg = 'logoutMessage'; + const dialogRef = Utils.showSuccessMessage( + resourceBundle, + successMsg, + logoutMsg, + dialog + ); + dialogRef.afterClosed().subscribe((res) => { + App.exitApp().catch((error) => { + console.log(error); + }); + }); + } + } + } diff --git a/src/app/core/components/dialog/dialog.component.ts b/src/app/core/components/dialog/dialog.component.ts index 08c2c8fc..ba1cd469 100644 --- a/src/app/core/components/dialog/dialog.component.ts +++ b/src/app/core/components/dialog/dialog.component.ts @@ -493,9 +493,10 @@ export class DialogComponent implements OnInit { } // Close the dialog when the user clicks on the "OK" button, and initiate the logout process. - onOkClick(): void { + async onOkClick() { this.dialogRef.close(); - this.logoutservice.logout(); + await this.logoutservice.logout(); + Utils.androidAppExit(this.resourceBundleJson, this.dialog); } setConsent() { diff --git a/src/app/core/components/header/header.component.ts b/src/app/core/components/header/header.component.ts index 5b1bbd1d..47ad533f 100644 --- a/src/app/core/components/header/header.component.ts +++ b/src/app/core/components/header/header.component.ts @@ -49,23 +49,7 @@ export class HeaderComponent implements OnInit { } async onItem() { await this.logoutService.logout(); - const isAndroidAppMode = environment.isAndroidAppMode == 'yes' ? true : false; - if (isAndroidAppMode) { - let resourceBundle = this.resourceBundleJson.dialogMessages; - let successMsg = 'success'; - let logoutMsg = 'logoutMessage'; - const dialogRef = Utils.showSuccessMessage( - resourceBundle, - successMsg, - logoutMsg, - this.dialog - ); - dialogRef.afterClosed().subscribe((res) => { - App.exitApp().catch((error) => { - console.log(error); - }); - }); - } + Utils.androidAppExit(this.resourceBundleJson, this.dialog); } async ngOnInit() { this.translate.use(this.userProfileService.getUserPreferredLanguage());