From b931765c064590e0dd59eb1b3be45737ea451bb7 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 24 Jun 2026 20:42:37 +0000 Subject: [PATCH] also remove video from the dom --- frontend/js/feed.js | 10 ++++++---- frontend/js/videos.js | 14 +++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/js/feed.js b/frontend/js/feed.js index 46d4388..160180b 100644 --- a/frontend/js/feed.js +++ b/frontend/js/feed.js @@ -422,14 +422,16 @@ App.feed = App.feed || {}; if (r < 0) return; const prevActive = state.feedActiveIndex; + // Drop the failed clip's feed slide element from the DOM, then its JSON + // from the queue, then re-key the remaining rendered slides. removeSlide(r); videos.splice(r, 1); reindexAfterRemoval(r); - // Keep the grid's parallel index-based virtualization in sync with the - // now-shorter queue. - if (App.virtualGrid && typeof App.virtualGrid.relayout === 'function') { - App.virtualGrid.relayout(); + // Remove the failed clip's grid card element from the DOM too (the grid + // shares the queue) and re-pack the remaining cards. + if (App.virtualGrid && typeof App.virtualGrid.removeVideo === 'function') { + App.virtualGrid.removeVideo(videoId); } if (videos.length === 0) { diff --git a/frontend/js/videos.js b/frontend/js/videos.js index 5499723..a66a95a 100644 --- a/frontend/js/videos.js +++ b/frontend/js/videos.js @@ -814,7 +814,19 @@ App.videos = App.videos || {}; if (el) { el.innerHTML = ''; el.style.height = '0px'; } }; - return { ensureInit, packFrom, update: scheduleUpdate, relayout, reset }; + // Removes a single video's card from the grid: its DOM element is + // unmounted directly (so it's gone even if the re-pack below can't run), + // then the remaining cards are re-packed against the now-shorter queue. + // The caller must have already removed the video from state.loadedVideos. + const removeVideo = function(videoId) { + const id = String(videoId); + mounted.forEach((card, i) => { + if (card.dataset.videoId === id) unmount(i); + }); + relayout(); + }; + + return { ensureInit, packFrom, update: scheduleUpdate, relayout, removeVideo, reset }; })(); App.videos.updateLoadMoreState = function() {