fix: robust mobile suspend and auth recovery
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user