diff --git a/tests/test_video_side_shell.py b/tests/test_video_side_shell.py index 70a530f2..c18ec8f8 100644 --- a/tests/test_video_side_shell.py +++ b/tests/test_video_side_shell.py @@ -158,6 +158,8 @@ def test_video_library_module_referenced_and_isolated(): assert stripped.startswith("/*") or stripped.startswith("(function") assert "(function" in _LIB_JS and "})();" in _LIB_JS assert "soulsync:video-page-shown" in _LIB_JS # decoupled via the event + # Cards/poster URLs use the SINGULAR kind (movie/show); the API uses plural. + assert "cardKind" in _LIB_JS and "apiKind" in _LIB_JS assert "addEventListener" in _LIB_JS assert "window." not in _LIB_JS diff --git a/webui/static/video/video-library.js b/webui/static/video/video-library.js index a7a20994..db1e3659 100644 --- a/webui/static/video/video-library.js +++ b/webui/static/video/video-library.js @@ -118,20 +118,21 @@ function load() { state.loaded = true; showLoading(true); - var kind = state.tab === 'movies' ? 'movies' : 'shows'; + var apiKind = state.tab === 'movies' ? 'movies' : 'shows'; // query param (plural) + var cardKind = state.tab === 'movies' ? 'movie' : 'show'; // card + poster URL (singular) var params = new URLSearchParams({ - kind: kind, search: state.search, letter: state.letter, sort: state.sort, + kind: apiKind, search: state.search, letter: state.letter, sort: state.sort, status: state.status, page: state.page, limit: state.limit }); fetch(LIBRARY_URL + '?' + params.toString(), { headers: { 'Accept': 'application/json' } }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (d) { showLoading(false); - if (!d || d.error) { renderItems([], kind); updatePagination(null); setCount(0); return; } - renderItems(d.items || [], kind); + if (!d || d.error) { renderItems([], cardKind); updatePagination(null); setCount(0); return; } + renderItems(d.items || [], cardKind); updatePagination(d.pagination); setCount(d.pagination ? d.pagination.total_count : 0); }) - .catch(function () { showLoading(false); renderItems([], kind); updatePagination(null); setCount(0); }); + .catch(function () { showLoading(false); renderItems([], cardKind); updatePagination(null); setCount(0); }); } function reload() { state.page = 1; load(); }