diff --git a/app/components/common/CommonPaginator.vue b/app/components/common/CommonPaginator.vue index 1849c27f..ad2056bb 100644 --- a/app/components/common/CommonPaginator.vue +++ b/app/components/common/CommonPaginator.vue @@ -45,7 +45,15 @@ defineSlots<{ const { t } = useI18n() const nuxtApp = useNuxtApp() -const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), eventType, preprocess) +const { + items, + prevItems, + update, + state, + endAnchor, + error, + canLoadMore, +} = usePaginator(paginator, toRef(() => stream), eventType, preprocess) nuxtApp.hook('elk-logo:click', () => { update() @@ -117,5 +125,18 @@ defineExpose({ createEntry, removeEntry, updateEntry })
{{ t('common.error') }}: {{ error }}
+ +
+ +

+ debug: canLoadMore="{{ canLoadMore }}" / state="{{ state }}" +

+
diff --git a/app/composables/paginator.ts b/app/composables/paginator.ts index 93aeed1f..444a2e98 100644 --- a/app/composables/paginator.ts +++ b/app/composables/paginator.ts @@ -18,6 +18,7 @@ export function usePaginator( const items = ref([]) const nextItems = ref([]) const prevItems = ref([]) + const canLoadMore = ref(true) const endAnchor = ref() const bound = useElementBounding(endAnchor) @@ -70,7 +71,7 @@ export function usePaginator( }, { immediate: true }) async function loadNext() { - if (state.value !== 'idle') + if (state.value !== 'idle' || !canLoadMore.value) return state.value = 'loading' @@ -99,6 +100,7 @@ export function usePaginator( error.value = e state.value = 'error' } + canLoadMore.value = false await nextTick() bound.update() @@ -123,6 +125,7 @@ export function usePaginator( && state.value === 'idle' // No new content is loaded when the keepAlive page enters the background && deactivated.value === false + && canLoadMore.value ) { loadNext() } @@ -137,5 +140,6 @@ export function usePaginator( state, error, endAnchor, + canLoadMore, } } diff --git a/locales/en.json b/locales/en.json index 2de4f66d..0a79f818 100644 --- a/locales/en.json +++ b/locales/en.json @@ -720,6 +720,7 @@ "year_past": "0 years ago|last year|{n} years ago" }, "timeline": { + "load_more": "Load more posts", "no_posts": "No posts here!", "show_new_items": "Show {v} new items|Show {v} new item|Show {v} new items", "view_older_posts": "Older posts from other instances may not be displayed."