fix: corregir race condition en favoritos con Supabase INITIAL_SESSION
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useFavoritesStore } from '@/stores/favorites'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getImageUrl as utilGetImageUrl } from '@/utils/imageUrl'
|
||||
import LoadingBranded from '@/components/common/LoadingBranded.vue'
|
||||
@ -9,6 +10,7 @@ import LoadingBranded from '@/components/common/LoadingBranded.vue'
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
const favoritesStore = useFavoritesStore()
|
||||
const authStore = useAuthStore()
|
||||
const selectedFilter = ref('all')
|
||||
|
||||
const filters = computed(() => [
|
||||
@ -20,9 +22,16 @@ const filters = computed(() => [
|
||||
{ key: 'stops', label: t('navigation.routes'), icon: 'location_on' }, // Reusing navigation.routes or adding a specific one
|
||||
])
|
||||
|
||||
onMounted(async () => {
|
||||
await favoritesStore.loadFavorites()
|
||||
})
|
||||
// Mismo patrón que FavoriteButton: esperar a que Supabase complete INITIAL_SESSION
|
||||
watch(
|
||||
() => authStore.isAuthenticated,
|
||||
(authenticated) => {
|
||||
if (authenticated) {
|
||||
favoritesStore.loadFavorites()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function getImageUrl(path?: string) {
|
||||
return utilGetImageUrl(path, 'business')
|
||||
|
||||
Reference in New Issue
Block a user