Skip to content

Commit 8556bd8

Browse files
committed
fix: load more when page increases
1 parent e167fb1 commit 8556bd8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

app/pages/search.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ onMounted(() => {
7373
7474
// Infinite scroll state
7575
const pageSize = 25
76-
const loadedPages = ref(1)
76+
const loadedPages = ref(2)
7777
const isLoadingMore = ref(false)
7878
7979
// Pagination state for table view
8080
const currentPage = ref(1)
81+
watch(currentPage, page => {
82+
loadedPages.value = Math.max(loadedPages.value, page + 1)
83+
})
8184
8285
// Get initial page from URL (for scroll restoration on reload)
8386
const initialPage = computed(() => {
@@ -109,6 +112,7 @@ watch([results, query], ([newResults, newQuery]) => {
109112
if (newResults) {
110113
cachedResults.value = newResults
111114
previousQuery.value = newQuery
115+
isLoadingMore.value = false
112116
}
113117
})
114118
@@ -246,11 +250,6 @@ function loadMore() {
246250
247251
isLoadingMore.value = true
248252
loadedPages.value++
249-
250-
// Reset loading state after data updates
251-
nextTick(() => {
252-
isLoadingMore.value = false
253-
})
254253
}
255254
256255
// Update URL when page changes from scrolling
@@ -988,6 +987,7 @@ defineOgImageComponent('Default', {
988987
v-model:mode="paginationMode"
989988
v-model:page-size="preferredPageSize"
990989
v-model:current-page="currentPage"
990+
:total-items="visibleResults?.total ?? displayResults.length"
991991
:view-mode="viewMode"
992992
/>
993993
</div>

0 commit comments

Comments
 (0)