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 { useI18n } from 'vue-i18n'
|
||||
import { useTaxiStore } from '@/stores/taxi'
|
||||
import { analyticsService } from '@/services/analyticsService'
|
||||
@ -18,13 +18,26 @@ const onlyEnglish = ref(false)
|
||||
const corregimientos = ['all', 'Boquete', 'David - Boquete', 'Boquete - David', 'Aeropuerto - Boquete']
|
||||
const shifts = ['all', 'dia', 'tarde', 'noche']
|
||||
|
||||
function fetchData() {
|
||||
taxiStore.loadTaxis()
|
||||
}
|
||||
|
||||
function handleRefocus() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
analyticsService.logEvent({ event_name: 'screen_view', screen_name: 'TaxisLocales' })
|
||||
window.addEventListener('app-refocus', handleRefocus)
|
||||
if(taxiStore.taxis.length === 0) {
|
||||
await taxiStore.loadTaxis()
|
||||
await fetchData()
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('app-refocus', handleRefocus)
|
||||
})
|
||||
|
||||
const filteredTaxis = computed(() => {
|
||||
return taxiStore.taxis.filter(taxi => {
|
||||
const matchesZone = selectedZone.value === 'all' || taxi.corregimiento === selectedZone.value
|
||||
|
||||
Reference in New Issue
Block a user