fix: implement global app-refocus listener and data recovery pattern in critical views to prevent infinite loading after app suspension

This commit is contained in:
2026-03-03 15:04:16 -05:00
parent cfe9286fcb
commit df0a4397f6
6 changed files with 96 additions and 12 deletions

View File

@ -144,8 +144,21 @@ function handleOutsideClick(e: MouseEvent) {
if (!target.closest('.route-selector')) dropdownOpen.value = false
}
async function fetchData() {
await routeStore.loadRoutes()
if (localSelectedRouteId.value) {
await scheduleStore.loadRouteSchedules(localSelectedRouteId.value)
}
}
function handleRefocus() {
fetchData()
}
onMounted(async () => {
analyticsService.logEvent({ event_name: 'screen_view', screen_name: 'Schedules' })
window.addEventListener('app-refocus', handleRefocus)
await routeStore.loadRoutes()
document.addEventListener('click', handleOutsideClick)
@ -177,6 +190,7 @@ const stopWatch = watch(
onUnmounted(() => {
stopWatch()
document.removeEventListener('click', handleOutsideClick)
window.removeEventListener('app-refocus', handleRefocus)
})
</script>