fix: robust mobile suspend and auth recovery

This commit is contained in:
2026-03-04 00:51:32 -05:00
parent bdfcd55370
commit 90bb93be17
11 changed files with 257 additions and 47 deletions

View File

@ -24,6 +24,13 @@ export const useFavoritesStore = defineStore('favorites', () => {
async function loadFavorites() {
isLoading.value = true
// Safety: si la red está inestable al awakening del background, no quedar cargando
const safetyTimer = setTimeout(() => {
if (isLoading.value) {
console.warn('SIBU | favoritesStore: safety timeout — reseteando isLoading')
isLoading.value = false
}
}, 12000)
try {
const { data: userData } = await supabase.auth.getUser()
if (!userData?.user) { favorites.value = []; return }
@ -37,6 +44,7 @@ export const useFavoritesStore = defineStore('favorites', () => {
} catch (error) {
console.error('Error loading favorites:', error)
} finally {
clearTimeout(safetyTimer)
isLoading.value = false
}
}