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

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref, computed } from 'vue'
import { onMounted, onUnmounted, ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { useShuttleStore } from '@/stores/shuttle'
@ -29,12 +29,25 @@ const verDetalle = (shuttleId: string) => {
})
}
function fetchData() {
shuttleStore.loadShuttles()
}
function handleRefocus() {
fetchData()
}
onMounted(async () => {
analyticsService.logEvent({ event_name: 'screen_view', screen_name: 'ViajesTuristicos' })
window.addEventListener('app-refocus', handleRefocus)
if(shuttleStore.shuttles.length === 0) {
await shuttleStore.loadShuttles()
await fetchData()
}
})
onUnmounted(() => {
window.removeEventListener('app-refocus', handleRefocus)
})
</script>
<template>