From b332a5afcccf760359d42c78831b694f8d3ddb46 Mon Sep 17 00:00:00 2001 From: Yashi002 Date: Mon, 27 Dec 2021 15:38:31 +0530 Subject: [PATCH 1/2] Improved: code to prepare loader on app mounted (#1x68xu9) --- changelogs/unreleased/-1x68xu9.yml | 6 ++++++ src/App.vue | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 changelogs/unreleased/-1x68xu9.yml diff --git a/changelogs/unreleased/-1x68xu9.yml b/changelogs/unreleased/-1x68xu9.yml new file mode 100644 index 000000000..605175e6e --- /dev/null +++ b/changelogs/unreleased/-1x68xu9.yml @@ -0,0 +1,6 @@ +--- +title: Improved Code to prepare loader on app mounted and assign it to null on dismiss +ticket_id: "#1x68u9" +merge_request: 29 +author: Yashi Verma +type: changed \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index a84d4623a..e7271532f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,27 +61,34 @@ export default defineComponent({ }, async presentLoader() { - this.loader = await loadingController - .create({ - message: this.$t("Click the backdrop to dismiss."), - translucent: true, - backdropDismiss: true - }); - await this.loader.present(); + if (!this.loader) { + this.loader = await loadingController + .create({ + message: this.$t("Click the backdrop to dismiss."), + translucent: true, + backdropDismiss: true + }); + } + this.loader.present(); }, dismissLoader() { if (this.loader) { this.loader.dismiss(); + this.loader = null as any; } } }, - mounted() { - emitter.on('timeZoneDifferent', this.timeZoneDifferentAlert); + async mounted() { + this.loader = await loadingController + .create({ + message: this.$t("Click the backdrop to dismiss."), + translucent: true, + backdropDismiss: true + }); emitter.on('presentLoader', this.presentLoader); emitter.on('dismissLoader', this.dismissLoader); }, unmounted() { - emitter.off('timeZoneDifferent', this.timeZoneDifferentAlert); emitter.off('presentLoader', this.presentLoader); emitter.off('dismissLoader', this.dismissLoader); }, From 51ba5d662cc620717696f7de58ef690aebbc16e1 Mon Sep 17 00:00:00 2001 From: Yashi002 Date: Mon, 27 Dec 2021 18:18:50 +0530 Subject: [PATCH 2/2] Updated requested changes --- src/App.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/App.vue b/src/App.vue index e7271532f..654755fa7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -79,6 +79,7 @@ export default defineComponent({ } }, async mounted() { + emitter.on('timeZoneDifferent', this.timeZoneDifferentAlert); this.loader = await loadingController .create({ message: this.$t("Click the backdrop to dismiss."), @@ -89,6 +90,7 @@ export default defineComponent({ emitter.on('dismissLoader', this.dismissLoader); }, unmounted() { + emitter.off('timeZoneDifferent', this.timeZoneDifferentAlert); emitter.off('presentLoader', this.presentLoader); emitter.off('dismissLoader', this.dismissLoader); },