PM-7392 - Desktop App comp - replace toast usage with simple dialog to guarantee users will see the reason for them being logged out.

This commit is contained in:
Jared Snider 2024-05-08 19:42:09 -04:00
parent bcf9099229
commit f731e9ba95
No known key found for this signature in database
GPG Key ID: A149DDD612516286
1 changed files with 18 additions and 20 deletions

View File

@ -570,11 +570,6 @@ export class AppComponent implements OnInit, OnDestroy {
private async displayLogoutReason(logoutReason: LogoutReason) { private async displayLogoutReason(logoutReason: LogoutReason) {
let toastOptions: ToastOptions; let toastOptions: ToastOptions;
// Since desktop has process reload on logout, some toasts are important enough to delay the logout
// until the toast is shown. We would eventually prefer to save off the message in state and show a banner
// on the login page after the reload.
// Note: most logout reasons are not important enough to delay the logout process so default to false
let delayLogoutToShowToast = false;
switch (logoutReason) { switch (logoutReason) {
case "sessionExpired": { case "sessionExpired": {
toastOptions = { toastOptions = {
@ -584,22 +579,26 @@ export class AppComponent implements OnInit, OnDestroy {
}; };
break; break;
} }
// We don't expect these scenarios to be common, but we want the user to
// understand why they are being logged out before a process reload.
case "accessTokenUnableToBeDecrypted": { case "accessTokenUnableToBeDecrypted": {
toastOptions = { await this.dialogService.openSimpleDialog({
variant: "error", title: { key: "loggedOut" },
title: this.i18nService.t("loggedOut"), content: { key: "accessTokenUnableToBeDecrypted" },
message: this.i18nService.t("accessTokenUnableToBeDecrypted"), acceptButtonText: { key: "ok" },
}; type: "info",
delayLogoutToShowToast = true; });
break; break;
} }
case "refreshTokenSecureStorageRetrievalFailure": { case "refreshTokenSecureStorageRetrievalFailure": {
toastOptions = { await this.dialogService.openSimpleDialog({
variant: "error", title: { key: "loggedOut" },
title: this.i18nService.t("loggedOut"), content: { key: "refreshTokenSecureStorageRetrievalFailure" },
message: this.i18nService.t("refreshTokenSecureStorageRetrievalFailure"), acceptButtonText: { key: "ok" },
}; type: "info",
delayLogoutToShowToast = true; });
break; break;
} }
default: { default: {
@ -612,9 +611,8 @@ export class AppComponent implements OnInit, OnDestroy {
} }
} }
const activeToast = this.toastService.showToast(toastOptions); if (toastOptions) {
if (delayLogoutToShowToast) { this.toastService.showToast(toastOptions);
await firstValueFrom(activeToast.onHidden);
} }
} }