From dd35a97be5cda796394e58cc558f0dad5c19658a Mon Sep 17 00:00:00 2001
From: Dan Niles <56271899+dan-niles@users.noreply.github.com>
Date: Thu, 8 Aug 2024 18:25:26 +0530
Subject: [PATCH 1/3] Implement infinite scroll for video/playlist lists
---
.../components/channel/tabs/PlaylistsTab.vue | 24 +++++----
.../src/components/channel/tabs/VideosTab.vue | 22 +++++---
.../src/components/playlist/PlaylistGrid.vue | 51 ++++++++++++++-----
.../playlist/panel/PlaylistPanel.vue | 50 ++++++++++++++----
zimui/src/components/video/VideoGrid.vue | 51 ++++++++++++++-----
zimui/src/views/PlaylistView.vue | 7 ++-
6 files changed, 149 insertions(+), 56 deletions(-)
diff --git a/zimui/src/components/channel/tabs/PlaylistsTab.vue b/zimui/src/components/channel/tabs/PlaylistsTab.vue
index 70cb4a7e..e67a110e 100644
--- a/zimui/src/components/channel/tabs/PlaylistsTab.vue
+++ b/zimui/src/components/channel/tabs/PlaylistsTab.vue
@@ -1,5 +1,5 @@
-
-
+
+
+
+
diff --git a/zimui/src/components/channel/tabs/VideosTab.vue b/zimui/src/components/channel/tabs/VideosTab.vue
index 71533f98..26e25174 100644
--- a/zimui/src/components/channel/tabs/VideosTab.vue
+++ b/zimui/src/components/channel/tabs/VideosTab.vue
@@ -1,5 +1,5 @@
-
-
+
+
+
+
+
+
+
diff --git a/zimui/src/components/playlist/PlaylistGrid.vue b/zimui/src/components/playlist/PlaylistGrid.vue
index 6f909ac4..ad0619fb 100644
--- a/zimui/src/components/playlist/PlaylistGrid.vue
+++ b/zimui/src/components/playlist/PlaylistGrid.vue
@@ -1,4 +1,5 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/zimui/src/components/playlist/panel/PlaylistPanel.vue b/zimui/src/components/playlist/panel/PlaylistPanel.vue
index 0973d147..c8b5aa75 100644
--- a/zimui/src/components/playlist/panel/PlaylistPanel.vue
+++ b/zimui/src/components/playlist/panel/PlaylistPanel.vue
@@ -6,6 +6,7 @@ import type { Playlist } from '@/types/Playlists'
import { LoopOptions } from '@/types/Playlists'
import PlaylistPanelItem from './PlaylistPanelItem.vue'
+import type { VideoPreview } from '@/types/Videos'
const { smAndDown } = useDisplay()
@@ -19,6 +20,8 @@ const props = defineProps<{
shuffle: boolean
}>()
+const isLoading = computed(() => props.playlist.videos.length === 0)
+
const windowHeight = ref(
window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
)
@@ -51,10 +54,35 @@ const scrollToCurrentVideo = () => {
}
const emit = defineEmits(['shuffle', 'loop', 'hide-panel'])
+
+const items = computed(() => props.playlist.videos.slice(0, 48))
+
+const loadMoreItems = async () => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(props.playlist.videos.slice(items.value.length, items.value.length + 12))
+ }, 100)
+ })
+}
+
+const load = async ({ done }: { done: (status: 'ok' | 'empty') => void }) => {
+ const res = await loadMoreItems()
+ items.value.push(...res)
+ if (
+ items.value[items.value.length - 1] == props.playlist.videos[props.playlist.videos.length - 1]
+ ) {
+ done('empty')
+ return
+ }
+ done('ok')
+}
-
+
+
+
+
@@ -111,15 +139,17 @@ const emit = defineEmits(['shuffle', 'loop', 'hide-panel'])
diff --git a/zimui/src/components/video/VideoGrid.vue b/zimui/src/components/video/VideoGrid.vue
index 163132cb..afcce561 100644
--- a/zimui/src/components/video/VideoGrid.vue
+++ b/zimui/src/components/video/VideoGrid.vue
@@ -1,4 +1,5 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/zimui/src/views/PlaylistView.vue b/zimui/src/views/PlaylistView.vue
index 6359a2a6..0b2295b6 100644
--- a/zimui/src/views/PlaylistView.vue
+++ b/zimui/src/views/PlaylistView.vue
@@ -18,6 +18,7 @@ const slug: string = route.params.slug as string
const playlist: Ref = ref() as Ref
const thumbnailSrc = ref('')
+const isLoading = ref(true)
// Fetch playlist data
const fetchPlaylistData = async function () {
@@ -26,6 +27,7 @@ const fetchPlaylistData = async function () {
const resp = await main.fetchPlaylist(slug)
if (resp) {
playlist.value = resp
+ isLoading.value = false
}
} catch (error) {
main.setErrorMessage('An unexpected error occured when fetching playlist data.')
@@ -70,7 +72,10 @@ const { mdAndDown } = useDisplay()
-
+
+
+
+
From 047e753d5d8f75b9a26dcbc1433f4d7f410c6a72 Mon Sep 17 00:00:00 2001
From: Dan Niles <56271899+dan-niles@users.noreply.github.com>
Date: Fri, 9 Aug 2024 13:27:40 +0530
Subject: [PATCH 2/3] Update CHANGELOG
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index be5705fe..72efdfec 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Disable preloading of subtitles in video.js in `zimui` (#38)
- Fix scraper to exit properly when `Too much videos failed to download` exceptions are raised (#285)
- Clean up temporary files properly in case of exceptions during scraper run (#288)
+- Implement infinite scroll for video/playlist lists and add loading spinners in `zimui` (#284)
## [3.0.0] - 2024-07-29
From d1930a05040e8a51b581c2be289d366f87a93806 Mon Sep 17 00:00:00 2001
From: Dan Niles <56271899+dan-niles@users.noreply.github.com>
Date: Fri, 9 Aug 2024 16:22:39 +0530
Subject: [PATCH 3/3] Change isLoading to ref and use length to find end of
list during infinite scroll
---
zimui/src/components/channel/tabs/PlaylistsTab.vue | 5 +++--
zimui/src/components/channel/tabs/VideosTab.vue | 5 +++--
zimui/src/components/playlist/PlaylistGrid.vue | 6 +++---
zimui/src/components/playlist/panel/PlaylistPanel.vue | 10 ++++------
zimui/src/components/video/VideoGrid.vue | 6 +++---
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/zimui/src/components/channel/tabs/PlaylistsTab.vue b/zimui/src/components/channel/tabs/PlaylistsTab.vue
index e67a110e..a06c7039 100644
--- a/zimui/src/components/channel/tabs/PlaylistsTab.vue
+++ b/zimui/src/components/channel/tabs/PlaylistsTab.vue
@@ -1,5 +1,5 @@