Skip to content

Commit

Permalink
Merge pull request #3822 from mikiher/episode-table-refresh-fix
Browse files Browse the repository at this point in the history
Episode table refresh fixes
  • Loading branch information
advplyr authored Jan 13, 2025
2 parents 8c4a928 + de5bc63 commit 9b5bdc1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
21 changes: 16 additions & 5 deletions client/components/tables/podcast/LazyEpisodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export default {
episodeComponentRefs: {},
windowHeight: 0,
episodesTableOffsetTop: 0,
episodeRowHeight: 176
episodeRowHeight: 176,
currScrollTop: 0
}
},
watch: {
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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()
})
}
},
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/PodcastController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b5bdc1

Please sign in to comment.