Skip to content

Commit 9b5bdc1

Browse files
authored
Merge pull request advplyr#3822 from mikiher/episode-table-refresh-fix
Episode table refresh fixes
2 parents 8c4a928 + de5bc63 commit 9b5bdc1

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

client/components/tables/podcast/LazyEpisodesTable.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export default {
8080
episodeComponentRefs: {},
8181
windowHeight: 0,
8282
episodesTableOffsetTop: 0,
83-
episodeRowHeight: 176
83+
episodeRowHeight: 176,
84+
currScrollTop: 0
8485
}
8586
},
8687
watch: {
@@ -484,9 +485,8 @@ export default {
484485
}
485486
}
486487
},
487-
scroll(evt) {
488-
if (!evt?.target?.scrollTop) return
489-
const scrollTop = Math.max(evt.target.scrollTop - this.episodesTableOffsetTop, 0)
488+
handleScroll() {
489+
const scrollTop = this.currScrollTop
490490
let firstEpisodeIndex = Math.floor(scrollTop / this.episodeRowHeight)
491491
let lastEpisodeIndex = Math.ceil((scrollTop + this.windowHeight) / this.episodeRowHeight)
492492
lastEpisodeIndex = Math.min(this.totalEpisodes - 1, lastEpisodeIndex)
@@ -501,6 +501,12 @@ export default {
501501
})
502502
this.mountEpisodes(firstEpisodeIndex, lastEpisodeIndex + 1)
503503
},
504+
scroll(evt) {
505+
if (!evt?.target?.scrollTop) return
506+
const scrollTop = Math.max(evt.target.scrollTop - this.episodesTableOffsetTop, 0)
507+
this.currScrollTop = scrollTop
508+
this.handleScroll()
509+
},
504510
initListeners() {
505511
const itemPageWrapper = document.getElementById('item-page-wrapper')
506512
if (itemPageWrapper) {
@@ -535,7 +541,12 @@ export default {
535541
this.episodesPerPage = Math.ceil(this.windowHeight / this.episodeRowHeight)
536542
537543
this.$nextTick(() => {
538-
this.mountEpisodes(0, Math.min(this.episodesPerPage, this.totalEpisodes))
544+
// Maybe update currScrollTop if items were removed
545+
const itemPageWrapper = document.getElementById('item-page-wrapper')
546+
const { scrollHeight, clientHeight } = itemPageWrapper
547+
const maxScrollTop = scrollHeight - clientHeight
548+
this.currScrollTop = Math.min(this.currScrollTop, maxScrollTop)
549+
this.handleScroll()
539550
})
540551
}
541552
},

server/controllers/PodcastController.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ class PodcastController {
461461
return res.sendStatus(404)
462462
}
463463

464+
// Remove it from the podcastEpisodes array
465+
req.libraryItem.media.podcastEpisodes = req.libraryItem.media.podcastEpisodes.filter((ep) => ep.id !== episodeId)
466+
464467
if (hardDelete) {
465468
const audioFile = episode.audioFile
466469
// TODO: this will trigger the watcher. should maybe handle this gracefully

0 commit comments

Comments
 (0)