From fc9e0287e4c34fee34257cd6c8685a8c043a5887 Mon Sep 17 00:00:00 2001 From: Will Sheldon <114631109+wssheldon@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:22:04 -0400 Subject: [PATCH] bugfix(case/ui): some escalate dialog resources never exit load state (#5021) --- .../dispatch/src/case/EscalateDialog.vue | 25 ++++++++++++++++++- .../static/dispatch/src/case/store.js | 19 +++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/dispatch/static/dispatch/src/case/EscalateDialog.vue b/src/dispatch/static/dispatch/src/case/EscalateDialog.vue index 4d25f459eb2f..689a7be27478 100644 --- a/src/dispatch/static/dispatch/src/case/EscalateDialog.vue +++ b/src/dispatch/static/dispatch/src/case/EscalateDialog.vue @@ -47,7 +47,9 @@ export default { name: "CaseEscalateDialog", data() { - return {} + return { + isIncidentDataLoaded: false, + } }, components: { @@ -83,6 +85,27 @@ export default { methods: { ...mapActions("case_management", ["getDetails", "closeEscalateDialog", "escalate"]), ...mapActions("incident", ["report", "resetSelected"]), + + async handleEscalate(incident) { + try { + this.loading = true + const incidentData = await this.escalate(incident) + this.$store.commit("incident/SET_SELECTED", incidentData) + this.isIncidentDataLoaded = true + } catch (error) { + console.error("Error escalating case:", error) + this.$store.commit( + "notification_backend/addBeNotification", + { + text: `Failed to escalate case.`, + type: "exception", + }, + { root: true } + ) + } finally { + this.loading = false + } + }, }, created() { diff --git a/src/dispatch/static/dispatch/src/case/store.js b/src/dispatch/static/dispatch/src/case/store.js index a0a66b349d19..2604db0357af 100644 --- a/src/dispatch/static/dispatch/src/case/store.js +++ b/src/dispatch/static/dispatch/src/case/store.js @@ -240,16 +240,17 @@ const actions = { return CaseApi.escalate(state.selected.id, payload).then((response) => { commit("incident/SET_SELECTED", response.data, { root: true }) commit("SET_SELECTED_LOADING", false) - var interval = setInterval(function () { - if (state.selected.id) { - dispatch("incident/get", response.data.id, { root: true }) - } - // TODO this is fragile but we don't set anything as "created" - if (state.selected.storage) { - clearInterval(interval) - } - }, 5000) + return new Promise((resolve) => { + const interval = setInterval(() => { + dispatch("incident/get", response.data.id, { root: true }).then((incidentData) => { + if (incidentData.conversation && incidentData.storage && incidentData.documents) { + clearInterval(interval) + resolve(incidentData) + } + }) + }, 5000) + }) }) }, report({ commit, dispatch }) {