From 5fe63cda956077a61965ad3c242ee2c84be7fb93 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 4 Apr 2022 08:02:46 +0200 Subject: [PATCH] MOBILE-3919 assign: Dismiss toast when leaving page --- src/addons/mod/assign/pages/edit/edit.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 4a5e59cfa..a1a29932e 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -73,6 +73,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { protected hasOffline = false; // Whether the assignment has offline data. protected isDestroyed = false; // Whether the component has been destroyed. protected forceLeave = false; // To allow leaving the page without checking for changes. + protected timeUpToast?: HTMLIonToastElement; constructor( protected route: ActivatedRoute, @@ -463,8 +464,8 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { /** * Function called when the time is up. */ - timeUp(): void { - CoreDomUtils.showToastWithOptions({ + async timeUp(): Promise { + this.timeUpToast = await CoreDomUtils.showToastWithOptions({ message: Translate.instant('addon.mod_assign.caneditsubmission'), duration: 0, buttons: [Translate.instant('core.dismiss')], @@ -477,6 +478,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { */ ngOnDestroy(): void { this.isDestroyed = true; + this.timeUpToast?.dismiss(); // Unblock the assignment. if (this.assign) {