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