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)
|
||||
|
||||
function loadEncounterAlerts() {
|
||||
if (confirmingAlert.value) return
|
||||
return alertStore.loadAlerts(props.encounterId)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ export const useAlertStore = defineStore('alerts', () => {
|
||||
async function pollOpenAlerts() {
|
||||
try {
|
||||
const items = await alertsApi.fetchAllOpenAlerts()
|
||||
alerts.value = items
|
||||
return applyPollResults(items)
|
||||
} catch (e) {
|
||||
console.error('Failed to poll alerts', e)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useAlertStore } from '@/stores/alerts'
|
||||
import { alertStatusToApiFilter } from '@/api/normalize'
|
||||
@@ -19,6 +19,17 @@ watch(activeFilter, (status) => {
|
||||
alertStore.loadGlobalAlerts(alertStatusToApiFilter(status))
|
||||
}, { 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) {
|
||||
if (!confirmingAlert.value) return
|
||||
await alertStore.acknowledge(confirmingAlert.value.id, note)
|
||||
|
||||
Reference in New Issue
Block a user