From 07491ae6095452fe45d8b25d8e9932ddf8872c51 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 28 Jun 2026 23:06:08 +0100 Subject: [PATCH] feat(media): paginate library video picker with total count Load the library 20 videos per page with Previous/Next controls, and show the total match count beside the "Search library" label. --- .../lesson/video/library-video.svelte | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/src/lib/features/course/components/lesson/video/library-video.svelte b/apps/dashboard/src/lib/features/course/components/lesson/video/library-video.svelte index bc363688..c7c1ebda 100644 --- a/apps/dashboard/src/lib/features/course/components/lesson/video/library-video.svelte +++ b/apps/dashboard/src/lib/features/course/components/lesson/video/library-video.svelte @@ -19,12 +19,17 @@ let { lessonId = '' }: Props = $props(); + const PAGE_SIZE = 20; + let search = $state(''); let isLoading = $state(false); let addingAssetId = $state(null); // Local copy so the fetch (which also backs the media manager page via the // shared mediaApi.assets store) doesn't leak removals between surfaces. let assets = $state([]); + let page = $state(1); + let totalPages = $state(1); + let totalCount = $state(0); // Asset ids already attached to this lesson, so the library hides them. const addedAssetIds = $derived( @@ -37,14 +42,18 @@ const visibleAssets = $derived(assets.filter((asset) => !addedAssetIds.has(asset.id))); - async function loadLibrary() { + async function loadLibrary(targetPage = 1) { isLoading = true; + page = targetPage; await mediaApi.listAssets({ kind: 'video', - limit: 100, + limit: PAGE_SIZE, + page: targetPage, search: search.trim() || undefined }); assets = mediaApi.assets.filter((asset) => asset.kind === 'video' && (asset.status ?? 'active') !== 'archived'); + totalPages = mediaApi.pagination?.totalPages ?? 1; + totalCount = mediaApi.pagination?.total ?? assets.length; isLoading = false; } @@ -79,12 +88,12 @@
-
@@ -135,4 +144,25 @@ {/each}
{/if} + + {#if totalPages > 1} +
+ +

+ {$t('media_manager.pagination.page')} + {page} + / {totalPages} +

+ +
+ {/if}