video Library: fix singular/plural kind bug (no posters + 'eps' on movies)
load() passed the plural API kind (movies/shows) to the card renderer + poster URL, which expect the singular (movie/show). Result: movie cards fell into the 'shows' branch (bogus '0/0 eps') and poster URLs were /api/video/poster/movies/.. -> 404 -> no images on either tab. Now apiKind (plural) is used for the query and cardKind (singular) for cards + poster proxy.
This commit is contained in:
parent
be141d0073
commit
9eecd6d2c4
2 changed files with 8 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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(); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue