mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-05-09 01:16:46 +02:00
Update episode list to come from component ref, populate queue from table order when playing episode
This commit is contained in:
parent
72169990ac
commit
fd1c8ee513
@ -89,13 +89,6 @@ export default {
|
|||||||
handler() {
|
handler() {
|
||||||
this.refresh()
|
this.refresh()
|
||||||
}
|
}
|
||||||
},
|
|
||||||
episodesList: {
|
|
||||||
handler(newList) {
|
|
||||||
const episodeIds = newList.map((ep) => ep.id)
|
|
||||||
this.$store.commit('setSortedEpisodeIds', episodeIds)
|
|
||||||
},
|
|
||||||
immediate: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -368,20 +361,20 @@ export default {
|
|||||||
playEpisode(episode) {
|
playEpisode(episode) {
|
||||||
const queueItems = []
|
const queueItems = []
|
||||||
|
|
||||||
const episodesInListeningOrder = this.episodesCopy.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' }))
|
const episodesInListeningOrder = this.episodesList
|
||||||
const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id)
|
const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id)
|
||||||
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
|
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
|
||||||
const episode = episodesInListeningOrder[i]
|
const _episode = episodesInListeningOrder[i]
|
||||||
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id)
|
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, _episode.id)
|
||||||
if (!podcastProgress || !podcastProgress.isFinished) {
|
if (!podcastProgress?.isFinished || episode.id === _episode.id) {
|
||||||
queueItems.push({
|
queueItems.push({
|
||||||
libraryItemId: this.libraryItem.id,
|
libraryItemId: this.libraryItem.id,
|
||||||
libraryId: this.libraryItem.libraryId,
|
libraryId: this.libraryItem.libraryId,
|
||||||
episodeId: episode.id,
|
episodeId: _episode.id,
|
||||||
title: episode.title,
|
title: _episode.title,
|
||||||
subtitle: this.mediaMetadata.title,
|
subtitle: this.mediaMetadata.title,
|
||||||
caption: episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
|
caption: _episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(_episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
|
||||||
duration: episode.audioFile.duration || null,
|
duration: _episode.audioFile.duration || null,
|
||||||
coverPath: this.media.coverPath || null
|
coverPath: this.media.coverPath || null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
<tables-tracks-table v-if="tracks.length" :title="$strings.LabelStatsAudioTracks" :tracks="tracksWithAudioFile" :is-file="isFile" :library-item-id="libraryItemId" class="mt-6" />
|
<tables-tracks-table v-if="tracks.length" :title="$strings.LabelStatsAudioTracks" :tracks="tracksWithAudioFile" :is-file="isFile" :library-item-id="libraryItemId" class="mt-6" />
|
||||||
|
|
||||||
<tables-podcast-lazy-episodes-table v-if="isPodcast" :library-item="libraryItem" />
|
<tables-podcast-lazy-episodes-table ref="episodesTable" v-if="isPodcast" :library-item="libraryItem" />
|
||||||
|
|
||||||
<tables-ebook-files-table v-if="ebookFiles.length" :library-item="libraryItem" class="mt-6" />
|
<tables-ebook-files-table v-if="ebookFiles.length" :library-item="libraryItem" class="mt-6" />
|
||||||
|
|
||||||
@ -267,9 +267,6 @@ export default {
|
|||||||
podcastEpisodes() {
|
podcastEpisodes() {
|
||||||
return this.media.episodes || []
|
return this.media.episodes || []
|
||||||
},
|
},
|
||||||
sortedEpisodeIds() {
|
|
||||||
return this.$store.getters.getSortedEpisodeIds
|
|
||||||
},
|
|
||||||
title() {
|
title() {
|
||||||
return this.mediaMetadata.title || 'No Title'
|
return this.mediaMetadata.title || 'No Title'
|
||||||
},
|
},
|
||||||
@ -537,8 +534,8 @@ export default {
|
|||||||
let episodeId = null
|
let episodeId = null
|
||||||
const queueItems = []
|
const queueItems = []
|
||||||
if (this.isPodcast) {
|
if (this.isPodcast) {
|
||||||
// Sort the episodes based on the sorting and filtering from the episode table component
|
// Uses the sorting and filtering from the episode table component
|
||||||
const episodesInListeningOrder = this.sortedEpisodeIds.map((id) => this.podcastEpisodes.find((ep) => ep.id === id))
|
const episodesInListeningOrder = this.$refs.episodesTable?.episodesList || []
|
||||||
|
|
||||||
// Find the first unplayed episode from the table
|
// Find the first unplayed episode from the table
|
||||||
let episodeIndex = episodesInListeningOrder.findIndex((ep) => {
|
let episodeIndex = episodesInListeningOrder.findIndex((ep) => {
|
||||||
|
@ -25,7 +25,6 @@ export const state = () => ({
|
|||||||
previousPath: '/',
|
previousPath: '/',
|
||||||
bookshelfBookIds: [],
|
bookshelfBookIds: [],
|
||||||
episodeTableEpisodeIds: [],
|
episodeTableEpisodeIds: [],
|
||||||
sortedEpisodeIds: [],
|
|
||||||
openModal: null,
|
openModal: null,
|
||||||
innerModalOpen: false,
|
innerModalOpen: false,
|
||||||
lastBookshelfScrollData: {},
|
lastBookshelfScrollData: {},
|
||||||
@ -62,9 +61,6 @@ export const getters = {
|
|||||||
getHomeBookshelfView: (state) => {
|
getHomeBookshelfView: (state) => {
|
||||||
if (!state.serverSettings || isNaN(state.serverSettings.homeBookshelfView)) return Constants.BookshelfView.STANDARD
|
if (!state.serverSettings || isNaN(state.serverSettings.homeBookshelfView)) return Constants.BookshelfView.STANDARD
|
||||||
return state.serverSettings.homeBookshelfView
|
return state.serverSettings.homeBookshelfView
|
||||||
},
|
|
||||||
getSortedEpisodeIds: (state) => {
|
|
||||||
return state.sortedEpisodeIds || []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,9 +146,6 @@ export const mutations = {
|
|||||||
setEpisodeTableEpisodeIds(state, val) {
|
setEpisodeTableEpisodeIds(state, val) {
|
||||||
state.episodeTableEpisodeIds = val || []
|
state.episodeTableEpisodeIds = val || []
|
||||||
},
|
},
|
||||||
setSortedEpisodeIds(state, episodeIds) {
|
|
||||||
state.sortedEpisodeIds = episodeIds || []
|
|
||||||
},
|
|
||||||
setPreviousPath(state, val) {
|
setPreviousPath(state, val) {
|
||||||
state.previousPath = val
|
state.previousPath = val
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user