fix: Acknowledge closing on alert polling update
This commit is contained in:
@@ -24,6 +24,7 @@ const { alerts, loading } = storeToRefs(alertStore)
|
|||||||
const confirmingAlert = ref(null)
|
const confirmingAlert = ref(null)
|
||||||
|
|
||||||
function loadEncounterAlerts() {
|
function loadEncounterAlerts() {
|
||||||
|
if (confirmingAlert.value) return
|
||||||
return alertStore.loadAlerts(props.encounterId)
|
return alertStore.loadAlerts(props.encounterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ export const useAlertStore = defineStore('alerts', () => {
|
|||||||
async function pollOpenAlerts() {
|
async function pollOpenAlerts() {
|
||||||
try {
|
try {
|
||||||
const items = await alertsApi.fetchAllOpenAlerts()
|
const items = await alertsApi.fetchAllOpenAlerts()
|
||||||
alerts.value = items
|
|
||||||
return applyPollResults(items)
|
return applyPollResults(items)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to poll alerts', e)
|
console.error('Failed to poll alerts', e)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useAlertStore } from '@/stores/alerts'
|
import { useAlertStore } from '@/stores/alerts'
|
||||||
import { alertStatusToApiFilter } from '@/api/normalize'
|
import { alertStatusToApiFilter } from '@/api/normalize'
|
||||||
@@ -19,6 +19,17 @@ watch(activeFilter, (status) => {
|
|||||||
alertStore.loadGlobalAlerts(alertStatusToApiFilter(status))
|
alertStore.loadGlobalAlerts(alertStatusToApiFilter(status))
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
|
let pollTimer = null
|
||||||
|
onMounted(() => {
|
||||||
|
pollTimer = setInterval(() => {
|
||||||
|
if (confirmingAlert.value) return
|
||||||
|
alertStore.loadGlobalAlerts(alertStatusToApiFilter(activeFilter.value))
|
||||||
|
}, 10_000)
|
||||||
|
})
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (pollTimer) clearInterval(pollTimer)
|
||||||
|
})
|
||||||
|
|
||||||
async function handleAcknowledge(note) {
|
async function handleAcknowledge(note) {
|
||||||
if (!confirmingAlert.value) return
|
if (!confirmingAlert.value) return
|
||||||
await alertStore.acknowledge(confirmingAlert.value.id, note)
|
await alertStore.acknowledge(confirmingAlert.value.id, note)
|
||||||
|
|||||||
Reference in New Issue
Block a user