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