Skip to content

Commit

Permalink
bugfix(case/ui): some escalate dialog resources never exit load state (
Browse files Browse the repository at this point in the history
  • Loading branch information
wssheldon authored Jul 26, 2024
1 parent 2254dd1 commit fc9e028
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
25 changes: 24 additions & 1 deletion src/dispatch/static/dispatch/src/case/EscalateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default {
name: "CaseEscalateDialog",
data() {
return {}
return {
isIncidentDataLoaded: false,
}
},
components: {
Expand Down Expand Up @@ -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() {
Expand Down
19 changes: 10 additions & 9 deletions src/dispatch/static/dispatch/src/case/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down

0 comments on commit fc9e028

Please sign in to comment.