From e8cb821e7ff16285fb6fc30c9da7b0a174201558 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Mon, 29 Sep 2025 21:43:14 -0400 Subject: [PATCH] Add message when you reach the bottom of the infinite scroll --- src/views/CategoryView.vue | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/views/CategoryView.vue b/src/views/CategoryView.vue index b362c03..701faf9 100644 --- a/src/views/CategoryView.vue +++ b/src/views/CategoryView.vue @@ -13,10 +13,12 @@ export default { async setup() { const data = ref() const status = ref<'ok' | 'error'>() + const endOfScroll = ref() // Display message when user reaches bottom of page return { data, - status + status, + endOfScroll } }, async mounted() { @@ -38,11 +40,13 @@ export default { const bottomOfWindow = document.documentElement.scrollTop + window.innerHeight === document.documentElement.offsetHeight - const streams = this.data!.streams + + if (!this.data) return + const streams = this.data.streams if (bottomOfWindow && streams) { // get cursor of the last stream rendered - const cursor = streams[streams.length - 1].cursor + const cursor = streams[streams.length - 1]?.cursor ?? null if (!cursor) return // get rest of streams from api @@ -52,14 +56,13 @@ export default { throw err }) - const lastStreamCursor = this.data!.streams[this.data!.streams.length - 1].cursor - const newLastStreamCursor = resData.streams[resData.streams.length - 1].cursor + const lastStreamCursor = this.data.streams[this.data.streams.length - 1]?.cursor ?? null + const newLastStreamCursor = resData.streams[resData.streams.length - 1]?.cursor ?? null if (lastStreamCursor === newLastStreamCursor) { - // Add "no more streams!" screen later - console.log('no more streams!') + this.endOfScroll = true; } else { for (const stream of resData.streams) { - this.data!.streams.push(stream) + this.data.streams.push(stream) } } } @@ -145,6 +148,9 @@ export default { > +
+ {{ $t('main.endOfScroll') }} +