diff --git a/frontend/src/features/listings/composables/useListingQuery.ts b/frontend/src/features/listings/composables/useListingQuery.ts index c42e6e1..5424116 100644 --- a/frontend/src/features/listings/composables/useListingQuery.ts +++ b/frontend/src/features/listings/composables/useListingQuery.ts @@ -122,14 +122,43 @@ export function useListingQuery( } ) + function restoreSnapshot(snapshot: { + listings: Listing[] + totalListings: number + zoneCounts: Record + currentPage: number + hasMoreListings: boolean + }) { + listings.value = snapshot.listings.slice() + totalListings.value = snapshot.totalListings + zoneCounts.value = { ...snapshot.zoneCounts } + currentPage.value = snapshot.currentPage + hasMoreListings.value = snapshot.hasMoreListings + loading.value = false + loadingMore.value = false + } + + function getSnapshot() { + return { + listings: listings.value.slice(), + totalListings: totalListings.value, + zoneCounts: { ...zoneCounts.value }, + currentPage: currentPage.value, + hasMoreListings: hasMoreListings.value, + } + } + return { loading, loadingMore, listings, totalListings, zoneCounts, + currentPage, hasMoreListings, loadListingsPage, zoneCount, + restoreSnapshot, + getSnapshot, } } diff --git a/frontend/src/features/listings/views/HomeView.vue b/frontend/src/features/listings/views/HomeView.vue index 7db1d46..88b3c85 100644 --- a/frontend/src/features/listings/views/HomeView.vue +++ b/frontend/src/features/listings/views/HomeView.vue @@ -1,6 +1,7 @@