@@ -53,6 +53,7 @@ const firstRenderSettled = ref(false)
5353const lastResolvedData = ref (defaultProductsResponse ())
5454const isRouteFetching = ref (false )
5555const filtersHydrated = ref (false )
56+ const routeFetchReady = ref (false )
5657
5758let searchDebounceTimeout: ReturnType <typeof setTimeout > | null = null
5859
@@ -182,7 +183,6 @@ const criticalImageLinks = computed(() => products.value
182183 as: ' image' ,
183184 href ,
184185 fetchpriority: ' high' ,
185- // crossorigin: ''
186186 })))
187187
188188useHead (() => ({
@@ -195,7 +195,6 @@ const categories = computed(() =>
195195 slug: category .slug ,
196196 label: getCategoryLabel (category .slug )
197197 }))
198- .sort ((left , right ) => left .label .localeCompare (right .label ))
199198)
200199
201200const allVisibleImagesReady = computed (() => {
@@ -388,14 +387,13 @@ const handlePageChange = (page: number) => {
388387
389388watch (
390389 () => route .fullPath ,
391- () => {
392- if (import .meta .server ) {
390+ (nextPath , previousPath ) => {
391+ if (import .meta .server || ! routeFetchReady . value || nextPath === previousPath ) {
393392 return
394393 }
395394
396395 void fetchRoutePage ()
397- },
398- { immediate: true }
396+ }
399397)
400398
401399watch (
@@ -456,12 +454,18 @@ watch(error, (currentError) => {
456454})
457455
458456onMounted (() => {
457+ routeFetchReady .value = true
458+
459459 requestAnimationFrame (() => {
460460 firstRenderSettled .value = true
461461 })
462462
463463 if (! products .value .length ) {
464- void recoverCatalogDataOnClient ()
464+ void fetchRoutePage ().finally (() => {
465+ if (! products .value .length ) {
466+ void recoverCatalogDataOnClient ()
467+ }
468+ })
465469 }
466470})
467471
0 commit comments