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:
@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user