diff --git a/frontend/src/stores/gallery.js b/frontend/src/stores/gallery.js index 0c4ca77..1a8245a 100644 --- a/frontend/src/stores/gallery.js +++ b/frontend/src/stores/gallery.js @@ -2,6 +2,13 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' import { useApi } from '../composables/useApi.js' +// Operator-confirmed 2026-05-30: fetch PAGE-sized chunks instead of one +// 50-item request so items render as each batch lands. Total initial +// count is unchanged (PAGE * INITIAL_BATCHES = 50). Infinite-scroll also +// pulls PAGE per trigger to keep appends progressive. +const PAGE = 5 +const INITIAL_BATCHES = 10 + export const useGalleryStore = defineStore('gallery', () => { const api = useApi() @@ -21,7 +28,13 @@ export const useGalleryStore = defineStore('gallery', () => { images.value = [] dateGroups.value = [] nextCursor.value = null - await loadMore() + // Sequentially fetch INITIAL_BATCHES chunks so items render as each + // batch lands rather than blocking on one big response. Stop early + // when the backend reports no more pages. + for (let i = 0; i < INITIAL_BATCHES; i++) { + if (i > 0 && nextCursor.value === null) break + await loadMore() + } } async function loadMore() { @@ -30,7 +43,7 @@ export const useGalleryStore = defineStore('gallery', () => { error.value = null const myId = ++inflightId try { - const params = { limit: 50, ...activeFilterParam() } + const params = { limit: PAGE, ...activeFilterParam() } if (nextCursor.value) params.cursor = nextCursor.value const body = await api.get('/api/gallery/scroll', { params }) if (myId !== inflightId) return // stale response diff --git a/frontend/src/views/ShowcaseView.vue b/frontend/src/views/ShowcaseView.vue index a091d84..63de41f 100644 --- a/frontend/src/views/ShowcaseView.vue +++ b/frontend/src/views/ShowcaseView.vue @@ -70,7 +70,7 @@ function onKeydown(e) { } onMounted(() => { - if (store.images.length === 0) store.fetchPage() + if (store.images.length === 0) store.loadInitial() window.addEventListener('keydown', onKeydown) }) onUnmounted(() => window.removeEventListener('keydown', onKeydown))