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 { ref, onMounted, computed } from 'vue'
import { ref, onMounted, onUnmounted, computed } from 'vue'
import { businessService } from '@/services/businessService'
import type { Business } from '@/types'
import { useRouter } from 'vue-router'
@ -54,9 +54,18 @@ async function loadBusinesses() {
}
}
function handleRefocus() {
loadBusinesses()
}
onMounted(() => {
analyticsService.logEvent({ event_name: 'screen_view', screen_name: 'Discover' })
loadBusinesses()
window.addEventListener('app-refocus', handleRefocus)
})
onUnmounted(() => {
window.removeEventListener('app-refocus', handleRefocus)
})
// ── Computados