From 5e2282ef760a44e9fab3ae6d26cddb0ffba6c967 Mon Sep 17 00:00:00 2001 From: mikiher Date: Sat, 11 Jan 2025 22:25:30 +0200 Subject: [PATCH 1/2] Fix LazyEpisodeTable.init to respect non-zero scrollTop --- .../tables/podcast/LazyEpisodesTable.vue | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/client/components/tables/podcast/LazyEpisodesTable.vue b/client/components/tables/podcast/LazyEpisodesTable.vue index 0dae11b36b..5e7b15ea52 100644 --- a/client/components/tables/podcast/LazyEpisodesTable.vue +++ b/client/components/tables/podcast/LazyEpisodesTable.vue @@ -80,7 +80,8 @@ export default { episodeComponentRefs: {}, windowHeight: 0, episodesTableOffsetTop: 0, - episodeRowHeight: 176 + episodeRowHeight: 176, + currScrollTop: 0 } }, watch: { @@ -484,9 +485,8 @@ export default { } } }, - scroll(evt) { - if (!evt?.target?.scrollTop) return - const scrollTop = Math.max(evt.target.scrollTop - this.episodesTableOffsetTop, 0) + handleScroll() { + const scrollTop = this.currScrollTop let firstEpisodeIndex = Math.floor(scrollTop / this.episodeRowHeight) let lastEpisodeIndex = Math.ceil((scrollTop + this.windowHeight) / this.episodeRowHeight) lastEpisodeIndex = Math.min(this.totalEpisodes - 1, lastEpisodeIndex) @@ -501,6 +501,12 @@ export default { }) this.mountEpisodes(firstEpisodeIndex, lastEpisodeIndex + 1) }, + scroll(evt) { + if (!evt?.target?.scrollTop) return + const scrollTop = Math.max(evt.target.scrollTop - this.episodesTableOffsetTop, 0) + this.currScrollTop = scrollTop + this.handleScroll() + }, initListeners() { const itemPageWrapper = document.getElementById('item-page-wrapper') if (itemPageWrapper) { @@ -535,7 +541,12 @@ export default { this.episodesPerPage = Math.ceil(this.windowHeight / this.episodeRowHeight) this.$nextTick(() => { - this.mountEpisodes(0, Math.min(this.episodesPerPage, this.totalEpisodes)) + // Maybe update currScrollTop if items were removed + const itemPageWrapper = document.getElementById('item-page-wrapper') + const { scrollHeight, clientHeight } = itemPageWrapper + const maxScrollTop = scrollHeight - clientHeight + this.currScrollTop = Math.min(this.currScrollTop, maxScrollTop) + this.handleScroll() }) } }, From de5bc63d880d4236aaf09f8a0a9b7a876bcee111 Mon Sep 17 00:00:00 2001 From: mikiher Date: Sat, 11 Jan 2025 22:26:36 +0200 Subject: [PATCH 2/2] Remove deleted episode from returned libraryItem object --- server/controllers/PodcastController.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/controllers/PodcastController.js b/server/controllers/PodcastController.js index 1d1c106d39..90b2c38364 100644 --- a/server/controllers/PodcastController.js +++ b/server/controllers/PodcastController.js @@ -461,6 +461,9 @@ class PodcastController { return res.sendStatus(404) } + // Remove it from the podcastEpisodes array + req.libraryItem.media.podcastEpisodes = req.libraryItem.media.podcastEpisodes.filter((ep) => ep.id !== episodeId) + if (hardDelete) { const audioFile = episode.audioFile // TODO: this will trigger the watcher. should maybe handle this gracefully