diff --git a/webui/static/video/video-watchlist.js b/webui/static/video/video-watchlist.js index 3819881b..e0377792 100644 --- a/webui/static/video/video-watchlist.js +++ b/webui/static/video/video-watchlist.js @@ -20,10 +20,11 @@ function wlBtn(opts) { return (window.VideoWatchlist) ? VideoWatchlist.btn(opts) : ''; } function cardHTML(it, kind) { - var href = kind === 'person' - ? '/video-detail/tmdb/person/' + it.tmdb_id - : (it.library_id ? '/video-detail/library/show/' + it.library_id - : '/video-detail/tmdb/show/' + it.tmdb_id); + // SPA open target: library shows open by library id ('library' source); + // people + un-owned shows open by tmdb id ('tmdb'). + var source = (kind === 'show' && it.library_id) ? 'library' : 'tmdb'; + var openId = source === 'library' ? it.library_id : it.tmdb_id; + var href = '/video-detail/' + source + '/' + kind + '/' + openId; var ph = kind === 'person' ? '👤' : '📺'; // 👤 / 📺 var art = it.poster_url ? '' + + 'data-vwlp-card="' + kind + '" data-vwlp-id="' + esc(it.tmdb_id) + '" ' + + 'data-vwlp-open="' + kind + '" data-vwlp-source="' + source + '" data-vwlp-openid="' + esc(openId) + '">' + '
' + art + '
' + btn + '
' + '
' + esc(it.title) + '
'; @@ -102,11 +104,31 @@ updateEmpty(); } + // Intercept card clicks → in-app SPA navigation (a bare would do a + // FULL page reload, re-downloading the whole app — ~15s freeze). The eye + // button's own capture-phase handler already stops its clicks from reaching + // here. Mirrors video-library.js. + function onGridClick(e) { + if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; // let new-tab work + var card = e.target.closest('[data-vwlp-open]'); + if (!card) return; + e.preventDefault(); + document.dispatchEvent(new CustomEvent('soulsync:video-open-detail', { + detail: { + kind: card.getAttribute('data-vwlp-open'), + id: parseInt(card.getAttribute('data-vwlp-openid'), 10), + source: card.getAttribute('data-vwlp-source') || 'library', + }, + })); + } + function wire() { var tabs = document.querySelectorAll('[data-vwlp-tab]'); for (var i = 0; i < tabs.length; i++) (function (b) { b.addEventListener('click', function () { setTab(b.getAttribute('data-vwlp-tab')); }); })(tabs[i]); + var grids = document.querySelectorAll('[data-vwlp-grid]'); + for (var j = 0; j < grids.length; j++) grids[j].addEventListener('click', onGridClick); document.addEventListener('soulsync:video-watchlist-changed', onChanged); }