2022-03-26 23:41:26 +01:00
|
|
|
<template>
|
2023-12-31 21:51:01 +01:00
|
|
|
<div id="lazy-episodes-table" class="w-full py-6">
|
2023-07-11 00:37:35 +02:00
|
|
|
<div class="flex flex-wrap flex-col md:flex-row md:items-center mb-4">
|
|
|
|
<div class="flex items-center flex-nowrap whitespace-nowrap mb-2 md:mb-0">
|
|
|
|
<p class="text-lg mb-0 font-semibold">{{ $strings.HeaderEpisodes }}</p>
|
|
|
|
<div class="inline-flex bg-white/5 px-1 mx-2 rounded-md text-sm text-gray-100">
|
|
|
|
<p v-if="episodesList.length === episodes.length">{{ episodes.length }}</p>
|
|
|
|
<p v-else>{{ episodesList.length }} / {{ episodes.length }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-05 01:13:46 +01:00
|
|
|
<div class="flex-grow hidden md:block" />
|
2023-07-11 00:37:35 +02:00
|
|
|
<div class="flex items-center">
|
|
|
|
<template v-if="isSelectionMode">
|
|
|
|
<ui-tooltip :text="selectedIsFinished ? $strings.MessageMarkAsNotFinished : $strings.MessageMarkAsFinished" direction="bottom">
|
|
|
|
<ui-read-icon-btn :disabled="processing" :is-read="selectedIsFinished" @click="toggleBatchFinished" class="mx-1.5" />
|
|
|
|
</ui-tooltip>
|
|
|
|
<ui-btn color="error" :disabled="processing" small class="h-9" @click="removeSelectedEpisodes">{{ $getString('MessageRemoveEpisodes', [selectedEpisodes.length]) }}</ui-btn>
|
|
|
|
<ui-btn :disabled="processing" small class="ml-2 h-9" @click="clearSelected">{{ $strings.ButtonCancel }}</ui-btn>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
2023-12-31 21:51:01 +01:00
|
|
|
<controls-filter-select v-model="filterKey" :items="filterItems" class="w-36 h-9 md:ml-4" @change="filterSortChanged" />
|
|
|
|
<controls-sort-select v-model="sortKey" :descending.sync="sortDesc" :items="sortItems" class="w-44 md:w-48 h-9 ml-1 sm:ml-4" @change="filterSortChanged" />
|
2023-07-11 00:37:35 +02:00
|
|
|
<div class="flex-grow md:hidden" />
|
|
|
|
<ui-context-menu-dropdown v-if="contextMenuItems.length" :items="contextMenuItems" class="ml-1" @action="contextMenuAction" />
|
|
|
|
</template>
|
|
|
|
</div>
|
2022-04-13 01:07:13 +02:00
|
|
|
</div>
|
2023-12-31 21:51:01 +01:00
|
|
|
<!-- <p v-if="!episodes.length" class="py-4 text-center text-lg">{{ $strings.MessageNoEpisodes }}</p> -->
|
2023-02-19 21:48:39 +01:00
|
|
|
<div v-if="episodes.length" class="w-full py-3 mx-auto flex">
|
|
|
|
<form @submit.prevent="submit" class="flex flex-grow">
|
2023-02-21 20:30:42 +01:00
|
|
|
<ui-text-input v-model="search" @input="inputUpdate" type="search" :placeholder="$strings.PlaceholderSearchEpisode" class="flex-grow mr-2 text-sm md:text-base" />
|
2023-02-19 21:48:39 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
2023-12-31 21:51:01 +01:00
|
|
|
<div class="relative min-h-[176px]">
|
|
|
|
<template v-for="episode in totalEpisodes">
|
|
|
|
<div :key="episode" :id="`episode-${episode - 1}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10">
|
|
|
|
<!-- episode is mounted here -->
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div v-if="isSearching" class="w-full h-full absolute inset-0 flex justify-center py-12" :class="{ 'bg-black/50': totalEpisodes }">
|
|
|
|
<ui-loading-indicator />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="!totalEpisodes" class="h-44 flex items-center justify-center">
|
|
|
|
<p class="text-lg">{{ $strings.MessageNoEpisodes }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-25 01:38:25 +02:00
|
|
|
|
2022-08-14 19:34:21 +02:00
|
|
|
<modals-podcast-remove-episode v-model="showPodcastRemoveModal" @input="removeEpisodeModalToggled" :library-item="libraryItem" :episodes="episodesToRemove" @clearSelected="clearSelected" />
|
2022-03-26 23:41:26 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-12-31 21:51:01 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
import LazyEpisodeRow from './LazyEpisodeRow.vue'
|
|
|
|
|
2022-03-26 23:41:26 +01:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
libraryItem: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-05-25 01:38:25 +02:00
|
|
|
episodesCopy: [],
|
2022-10-25 00:57:08 +02:00
|
|
|
filterKey: 'incomplete',
|
2022-05-24 02:28:00 +02:00
|
|
|
sortKey: 'publishedAt',
|
2022-05-25 01:38:25 +02:00
|
|
|
sortDesc: true,
|
|
|
|
selectedEpisode: null,
|
2022-08-14 19:34:21 +02:00
|
|
|
showPodcastRemoveModal: false,
|
|
|
|
selectedEpisodes: [],
|
2022-08-28 21:47:31 +02:00
|
|
|
episodesToRemove: [],
|
2023-01-05 01:13:46 +01:00
|
|
|
processing: false,
|
2023-02-19 21:48:39 +01:00
|
|
|
search: null,
|
|
|
|
searchTimeout: null,
|
2023-12-31 21:51:01 +01:00
|
|
|
searchText: null,
|
|
|
|
isSearching: false,
|
|
|
|
totalEpisodes: 0,
|
|
|
|
episodesPerPage: null,
|
|
|
|
episodeIndexesMounted: [],
|
|
|
|
episodeComponentRefs: {},
|
|
|
|
windowHeight: 0,
|
|
|
|
episodesTableOffsetTop: 0,
|
|
|
|
episodeRowHeight: 176
|
2022-11-09 00:10:08 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2023-01-05 01:13:46 +01:00
|
|
|
libraryItem: {
|
|
|
|
handler() {
|
2024-01-05 21:38:29 +01:00
|
|
|
this.refresh()
|
2023-01-05 01:13:46 +01:00
|
|
|
}
|
2022-11-09 00:10:08 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-01-05 01:13:46 +01:00
|
|
|
contextMenuItems() {
|
|
|
|
if (!this.userIsAdminOrUp) return []
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
text: 'Quick match all episodes',
|
|
|
|
action: 'quick-match-episodes'
|
2023-07-15 18:27:06 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.allEpisodesFinished ? this.$strings.MessageMarkAllEpisodesNotFinished : this.$strings.MessageMarkAllEpisodesFinished,
|
|
|
|
action: 'batch-mark-as-finished'
|
2023-01-05 01:13:46 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2022-11-09 00:10:08 +01:00
|
|
|
sortItems() {
|
|
|
|
return [
|
2022-10-29 01:10:19 +02:00
|
|
|
{
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelPubDate,
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'publishedAt'
|
|
|
|
},
|
|
|
|
{
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelTitle,
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'title'
|
|
|
|
},
|
|
|
|
{
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelSeason,
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'season'
|
|
|
|
},
|
|
|
|
{
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelEpisode,
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'episode'
|
|
|
|
}
|
2022-11-09 00:10:08 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
filterItems() {
|
|
|
|
return [
|
2022-10-29 22:33:38 +02:00
|
|
|
{
|
|
|
|
value: 'all',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelShowAll
|
2022-10-29 22:33:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'incomplete',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelIncomplete
|
2022-10-29 22:33:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'complete',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelComplete
|
2022-10-29 22:33:38 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'in_progress',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelInProgress
|
2022-10-29 22:33:38 +02:00
|
|
|
}
|
2022-10-29 01:10:19 +02:00
|
|
|
]
|
2022-11-09 00:10:08 +01:00
|
|
|
},
|
2022-08-14 19:34:21 +02:00
|
|
|
isSelectionMode() {
|
|
|
|
return this.selectedEpisodes.length > 0
|
|
|
|
},
|
2023-01-05 01:13:46 +01:00
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2022-04-13 01:07:13 +02:00
|
|
|
},
|
2022-03-26 23:41:26 +01:00
|
|
|
media() {
|
|
|
|
return this.libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
|
|
|
episodes() {
|
|
|
|
return this.media.episodes || []
|
2022-05-25 01:38:25 +02:00
|
|
|
},
|
|
|
|
episodesSorted() {
|
2022-10-25 00:57:08 +02:00
|
|
|
return this.episodesCopy
|
|
|
|
.filter((ep) => {
|
|
|
|
if (this.filterKey === 'all') return true
|
|
|
|
const episodeProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, ep.id)
|
|
|
|
if (this.filterKey === 'incomplete') return !episodeProgress || !episodeProgress.isFinished
|
|
|
|
if (this.filterKey === 'complete') return episodeProgress && episodeProgress.isFinished
|
|
|
|
return episodeProgress && !episodeProgress.isFinished
|
|
|
|
})
|
|
|
|
.sort((a, b) => {
|
2023-04-10 00:20:56 +02:00
|
|
|
let aValue = a[this.sortKey]
|
|
|
|
let bValue = b[this.sortKey]
|
|
|
|
|
|
|
|
// Sort episodes with no pub date as the oldest
|
|
|
|
if (this.sortKey === 'publishedAt') {
|
|
|
|
if (!aValue) aValue = Number.MAX_VALUE
|
|
|
|
if (!bValue) bValue = Number.MAX_VALUE
|
|
|
|
}
|
|
|
|
|
2022-10-25 00:57:08 +02:00
|
|
|
if (this.sortDesc) {
|
2023-04-10 00:20:56 +02:00
|
|
|
return String(bValue).localeCompare(String(aValue), undefined, { numeric: true, sensitivity: 'base' })
|
2022-10-25 00:57:08 +02:00
|
|
|
}
|
2023-04-10 00:20:56 +02:00
|
|
|
return String(aValue).localeCompare(String(bValue), undefined, { numeric: true, sensitivity: 'base' })
|
2022-10-25 00:57:08 +02:00
|
|
|
})
|
2022-08-28 21:47:31 +02:00
|
|
|
},
|
2023-02-19 21:48:39 +01:00
|
|
|
episodesList() {
|
|
|
|
return this.episodesSorted.filter((episode) => {
|
|
|
|
if (!this.searchText) return true
|
2023-07-11 00:37:35 +02:00
|
|
|
return episode.title?.toLowerCase().includes(this.searchText) || episode.subtitle?.toLowerCase().includes(this.searchText)
|
2023-02-19 21:48:39 +01:00
|
|
|
})
|
|
|
|
},
|
2022-08-28 21:47:31 +02:00
|
|
|
selectedIsFinished() {
|
|
|
|
// Find an item that is not finished, if none then all items finished
|
2023-07-15 18:27:06 +02:00
|
|
|
return !this.selectedEpisodes.some((episode) => {
|
|
|
|
const itemProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id)
|
|
|
|
return !itemProgress?.isFinished
|
|
|
|
})
|
|
|
|
},
|
|
|
|
allEpisodesFinished() {
|
|
|
|
return !this.episodesSorted.some((episode) => {
|
|
|
|
const itemProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id)
|
|
|
|
return !itemProgress?.isFinished
|
2022-08-28 21:47:31 +02:00
|
|
|
})
|
2023-02-27 19:04:26 +01:00
|
|
|
},
|
|
|
|
dateFormat() {
|
|
|
|
return this.$store.state.serverSettings.dateFormat
|
|
|
|
},
|
|
|
|
timeFormat() {
|
|
|
|
return this.$store.state.serverSettings.timeFormat
|
2022-03-26 23:41:26 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-09-30 22:12:37 +02:00
|
|
|
submit() {},
|
2023-02-19 21:48:39 +01:00
|
|
|
inputUpdate() {
|
|
|
|
clearTimeout(this.searchTimeout)
|
2023-12-31 21:51:01 +01:00
|
|
|
this.isSearching = true
|
|
|
|
let searchStart = this.searchText
|
2023-02-19 21:48:39 +01:00
|
|
|
this.searchTimeout = setTimeout(() => {
|
2023-12-31 21:51:01 +01:00
|
|
|
this.isSearching = false
|
|
|
|
if (!this.search?.trim()) {
|
2023-02-19 21:48:39 +01:00
|
|
|
this.searchText = ''
|
2023-12-31 21:51:01 +01:00
|
|
|
} else {
|
|
|
|
this.searchText = this.search.toLowerCase().trim()
|
|
|
|
}
|
|
|
|
if (searchStart !== this.searchText) {
|
|
|
|
this.init()
|
2023-02-19 21:48:39 +01:00
|
|
|
}
|
2023-12-31 21:51:01 +01:00
|
|
|
}, 750)
|
2023-02-19 21:48:39 +01:00
|
|
|
},
|
2023-05-30 00:38:38 +02:00
|
|
|
contextMenuAction({ action }) {
|
2023-01-05 01:13:46 +01:00
|
|
|
if (action === 'quick-match-episodes') {
|
2023-07-15 18:27:06 +02:00
|
|
|
if (this.processing) return
|
2023-01-05 01:13:46 +01:00
|
|
|
|
|
|
|
this.quickMatchAllEpisodes()
|
2023-07-15 18:27:06 +02:00
|
|
|
} else if (action === 'batch-mark-as-finished') {
|
|
|
|
if (this.processing) return
|
|
|
|
|
|
|
|
this.markAllEpisodesFinished()
|
2023-01-05 01:13:46 +01:00
|
|
|
}
|
|
|
|
},
|
2023-07-15 18:27:06 +02:00
|
|
|
markAllEpisodesFinished() {
|
|
|
|
const newIsFinished = !this.allEpisodesFinished
|
|
|
|
const payload = {
|
|
|
|
message: newIsFinished ? this.$strings.MessageConfirmMarkAllEpisodesFinished : this.$strings.MessageConfirmMarkAllEpisodesNotFinished,
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
2024-08-11 18:53:30 +02:00
|
|
|
this.batchUpdateEpisodesFinished(this.episodesCopy, newIsFinished)
|
2023-07-15 18:27:06 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
},
|
2023-01-05 01:13:46 +01:00
|
|
|
quickMatchAllEpisodes() {
|
|
|
|
if (!this.mediaMetadata.feedUrl) {
|
|
|
|
this.$toast.error(this.$strings.MessagePodcastHasNoRSSFeedForMatching)
|
|
|
|
return
|
|
|
|
}
|
2023-07-15 18:27:06 +02:00
|
|
|
this.processing = true
|
2023-01-05 01:13:46 +01:00
|
|
|
|
|
|
|
const payload = {
|
|
|
|
message: 'Quick matching episodes will overwrite details if a match is found. Only unmatched episodes will be updated. Are you sure?',
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
|
|
|
this.$axios
|
|
|
|
.$post(`/api/podcasts/${this.libraryItem.id}/match-episodes?override=1`)
|
|
|
|
.then((data) => {
|
|
|
|
if (data.numEpisodesUpdated) {
|
|
|
|
this.$toast.success(`${data.numEpisodesUpdated} episodes updated`)
|
|
|
|
} else {
|
2024-08-31 00:47:49 +02:00
|
|
|
this.$toast.info(this.$strings.ToastNoUpdatesNecessary)
|
2023-01-05 01:13:46 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to request match episodes', error)
|
|
|
|
this.$toast.error('Failed to match episodes')
|
|
|
|
})
|
|
|
|
}
|
2023-07-15 18:27:06 +02:00
|
|
|
this.processing = false
|
2023-01-05 01:13:46 +01:00
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
},
|
2022-11-27 19:33:38 +01:00
|
|
|
addToPlaylist(episode) {
|
|
|
|
this.$store.commit('globals/setSelectedPlaylistItems', [{ libraryItem: this.libraryItem, episode }])
|
|
|
|
this.$store.commit('globals/setShowPlaylistsModal', true)
|
|
|
|
},
|
2022-11-12 22:41:41 +01:00
|
|
|
addEpisodeToQueue(episode) {
|
|
|
|
const queueItem = {
|
|
|
|
libraryItemId: this.libraryItem.id,
|
|
|
|
libraryId: this.libraryItem.libraryId,
|
|
|
|
episodeId: episode.id,
|
|
|
|
title: episode.title,
|
|
|
|
subtitle: this.mediaMetadata.title,
|
2024-08-31 00:47:49 +02:00
|
|
|
caption: episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
|
2022-11-12 22:41:41 +01:00
|
|
|
duration: episode.audioFile.duration || null,
|
|
|
|
coverPath: this.media.coverPath || null
|
|
|
|
}
|
|
|
|
this.$store.commit('addItemToQueue', queueItem)
|
|
|
|
},
|
2022-08-28 21:47:31 +02:00
|
|
|
toggleBatchFinished() {
|
2023-07-15 18:27:06 +02:00
|
|
|
this.batchUpdateEpisodesFinished(this.selectedEpisodes, !this.selectedIsFinished)
|
|
|
|
},
|
|
|
|
batchUpdateEpisodesFinished(episodes, newIsFinished) {
|
2024-08-11 18:53:30 +02:00
|
|
|
if (!episodes.length) return
|
2022-08-28 21:47:31 +02:00
|
|
|
this.processing = true
|
2023-07-15 18:27:06 +02:00
|
|
|
|
|
|
|
const updateProgressPayloads = episodes.map((episode) => {
|
2022-08-28 21:47:31 +02:00
|
|
|
return {
|
|
|
|
libraryItemId: this.libraryItem.id,
|
|
|
|
episodeId: episode.id,
|
|
|
|
isFinished: newIsFinished
|
|
|
|
}
|
|
|
|
})
|
2023-07-15 18:27:06 +02:00
|
|
|
return this.$axios
|
2022-08-28 21:47:31 +02:00
|
|
|
.patch(`/api/me/progress/batch/update`, updateProgressPayloads)
|
|
|
|
.then(() => {
|
2022-11-09 00:10:08 +01:00
|
|
|
this.$toast.success(this.$strings.ToastBatchUpdateSuccess)
|
2022-08-28 21:47:31 +02:00
|
|
|
this.processing = false
|
|
|
|
this.clearSelected()
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
2022-11-09 00:10:08 +01:00
|
|
|
this.$toast.error(this.$strings.ToastBatchUpdateFailed)
|
2022-08-28 21:47:31 +02:00
|
|
|
console.error('Failed to batch update read/not read', error)
|
|
|
|
this.processing = false
|
|
|
|
})
|
|
|
|
},
|
2022-08-14 19:34:21 +02:00
|
|
|
removeEpisodeModalToggled(val) {
|
|
|
|
if (!val) this.episodesToRemove = []
|
|
|
|
},
|
|
|
|
clearSelected() {
|
|
|
|
this.selectedEpisodes = []
|
2023-12-31 21:51:01 +01:00
|
|
|
this.setSelectionModeForEpisodes()
|
2022-08-14 19:34:21 +02:00
|
|
|
},
|
|
|
|
removeSelectedEpisodes() {
|
|
|
|
this.episodesToRemove = this.selectedEpisodes
|
|
|
|
this.showPodcastRemoveModal = true
|
|
|
|
},
|
|
|
|
episodeSelected({ isSelected, episode }) {
|
2023-12-31 21:51:01 +01:00
|
|
|
let isSelectionModeBefore = this.isSelectionMode
|
2022-08-14 19:34:21 +02:00
|
|
|
if (isSelected) {
|
|
|
|
this.selectedEpisodes.push(episode)
|
|
|
|
} else {
|
|
|
|
this.selectedEpisodes = this.selectedEpisodes.filter((ep) => ep.id !== episode.id)
|
|
|
|
}
|
2023-12-31 21:51:01 +01:00
|
|
|
if (this.isSelectionMode !== isSelectionModeBefore) {
|
|
|
|
this.setSelectionModeForEpisodes()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setSelectionModeForEpisodes() {
|
|
|
|
for (const key in this.episodeComponentRefs) {
|
|
|
|
if (this.episodeComponentRefs[key]?.setSelectionMode) {
|
|
|
|
this.episodeComponentRefs[key].setSelectionMode(this.isSelectionMode)
|
|
|
|
}
|
|
|
|
}
|
2022-08-14 19:34:21 +02:00
|
|
|
},
|
2022-08-28 20:12:38 +02:00
|
|
|
playEpisode(episode) {
|
|
|
|
const queueItems = []
|
2022-09-02 00:11:57 +02:00
|
|
|
|
|
|
|
const episodesInListeningOrder = this.episodesCopy.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' }))
|
|
|
|
const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id)
|
|
|
|
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
|
|
|
|
const episode = episodesInListeningOrder[i]
|
|
|
|
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id)
|
|
|
|
if (!podcastProgress || !podcastProgress.isFinished) {
|
|
|
|
queueItems.push({
|
|
|
|
libraryItemId: this.libraryItem.id,
|
2022-11-12 22:41:41 +01:00
|
|
|
libraryId: this.libraryItem.libraryId,
|
2022-09-02 00:11:57 +02:00
|
|
|
episodeId: episode.id,
|
|
|
|
title: episode.title,
|
|
|
|
subtitle: this.mediaMetadata.title,
|
2024-08-31 00:47:49 +02:00
|
|
|
caption: episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
|
2022-09-02 00:11:57 +02:00
|
|
|
duration: episode.audioFile.duration || null,
|
|
|
|
coverPath: this.media.coverPath || null
|
|
|
|
})
|
|
|
|
}
|
2022-08-28 20:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItem.id,
|
|
|
|
episodeId: episode.id,
|
|
|
|
queueItems
|
|
|
|
})
|
|
|
|
},
|
2022-05-25 01:38:25 +02:00
|
|
|
removeEpisode(episode) {
|
2022-08-14 19:34:21 +02:00
|
|
|
this.episodesToRemove = [episode]
|
2022-05-25 01:38:25 +02:00
|
|
|
this.showPodcastRemoveModal = true
|
|
|
|
},
|
2022-03-27 22:37:04 +02:00
|
|
|
editEpisode(episode) {
|
2023-03-04 20:04:55 +01:00
|
|
|
const episodeIds = this.episodesSorted.map((e) => e.id)
|
|
|
|
this.$store.commit('setEpisodeTableEpisodeIds', episodeIds)
|
2022-04-23 02:31:11 +02:00
|
|
|
this.$store.commit('setSelectedLibraryItem', this.libraryItem)
|
|
|
|
this.$store.commit('globals/setSelectedEpisode', episode)
|
|
|
|
this.$store.commit('globals/setShowEditPodcastEpisodeModal', true)
|
2022-05-25 01:38:25 +02:00
|
|
|
},
|
2022-05-28 18:38:51 +02:00
|
|
|
viewEpisode(episode) {
|
|
|
|
this.$store.commit('setSelectedLibraryItem', this.libraryItem)
|
|
|
|
this.$store.commit('globals/setSelectedEpisode', episode)
|
|
|
|
this.$store.commit('globals/setShowViewPodcastEpisodeModal', true)
|
|
|
|
},
|
2023-12-31 21:51:01 +01:00
|
|
|
destroyEpisodeComponents() {
|
|
|
|
for (const key in this.episodeComponentRefs) {
|
|
|
|
if (this.episodeComponentRefs[key]?.destroy) {
|
|
|
|
this.episodeComponentRefs[key].destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.episodeComponentRefs = {}
|
|
|
|
this.episodeIndexesMounted = []
|
|
|
|
},
|
|
|
|
mountEpisode(index) {
|
|
|
|
const episodeEl = document.getElementById(`episode-${index}`)
|
|
|
|
if (!episodeEl) {
|
|
|
|
console.warn('Episode row el not found at ' + index)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.episodeIndexesMounted.push(index)
|
|
|
|
|
|
|
|
if (this.episodeComponentRefs[index]) {
|
|
|
|
const episodeComponent = this.episodeComponentRefs[index]
|
|
|
|
episodeEl.appendChild(episodeComponent.$el)
|
|
|
|
if (this.isSelectionMode) {
|
|
|
|
episodeComponent.setSelectionMode(true)
|
|
|
|
if (this.selectedEpisodes.some((i) => i.id === episodeComponent.episodeId)) {
|
|
|
|
episodeComponent.isSelected = true
|
|
|
|
} else {
|
|
|
|
episodeComponent.isSelected = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
episodeComponent.setSelectionMode(false)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const _this = this
|
|
|
|
const ComponentClass = Vue.extend(LazyEpisodeRow)
|
|
|
|
const instance = new ComponentClass({
|
|
|
|
propsData: {
|
|
|
|
index,
|
|
|
|
libraryItemId: this.libraryItem.id,
|
|
|
|
episode: this.episodesList[index]
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.$on('selected', (payload) => {
|
|
|
|
_this.episodeSelected(payload)
|
|
|
|
})
|
|
|
|
this.$on('view', (payload) => {
|
|
|
|
_this.viewEpisode(payload)
|
|
|
|
})
|
|
|
|
this.$on('play', (payload) => {
|
|
|
|
_this.playEpisode(payload)
|
|
|
|
})
|
|
|
|
this.$on('addToQueue', (payload) => {
|
|
|
|
_this.addEpisodeToQueue(payload)
|
|
|
|
})
|
|
|
|
this.$on('remove', (payload) => {
|
|
|
|
_this.removeEpisode(payload)
|
|
|
|
})
|
|
|
|
this.$on('edit', (payload) => {
|
|
|
|
_this.editEpisode(payload)
|
|
|
|
})
|
|
|
|
this.$on('addToPlaylist', (payload) => {
|
|
|
|
_this.addToPlaylist(payload)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.episodeComponentRefs[index] = instance
|
|
|
|
instance.$mount()
|
|
|
|
episodeEl.appendChild(instance.$el)
|
|
|
|
|
|
|
|
if (this.isSelectionMode) {
|
|
|
|
instance.setSelectionMode(true)
|
|
|
|
if (this.selectedEpisodes.some((i) => i.id === this.episodesList[index].id)) {
|
|
|
|
instance.isSelected = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mountEpisodes(startIndex, endIndex) {
|
|
|
|
for (let i = startIndex; i < endIndex; i++) {
|
|
|
|
if (!this.episodeIndexesMounted.includes(i)) {
|
|
|
|
this.mountEpisode(i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scroll(evt) {
|
|
|
|
if (!evt?.target?.scrollTop) return
|
|
|
|
const scrollTop = Math.max(evt.target.scrollTop - this.episodesTableOffsetTop, 0)
|
|
|
|
let firstEpisodeIndex = Math.floor(scrollTop / this.episodeRowHeight)
|
|
|
|
let lastEpisodeIndex = Math.ceil((scrollTop + this.windowHeight) / this.episodeRowHeight)
|
|
|
|
lastEpisodeIndex = Math.min(this.totalEpisodes - 1, lastEpisodeIndex)
|
|
|
|
|
|
|
|
this.episodeIndexesMounted = this.episodeIndexesMounted.filter((_index) => {
|
|
|
|
if (_index < firstEpisodeIndex || _index >= lastEpisodeIndex) {
|
|
|
|
const el = document.getElementById(`lazy-episode-${_index}`)
|
|
|
|
if (el) el.remove()
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
this.mountEpisodes(firstEpisodeIndex, lastEpisodeIndex + 1)
|
|
|
|
},
|
|
|
|
initListeners() {
|
|
|
|
const itemPageWrapper = document.getElementById('item-page-wrapper')
|
|
|
|
if (itemPageWrapper) {
|
|
|
|
itemPageWrapper.addEventListener('scroll', this.scroll)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeListeners() {
|
|
|
|
const itemPageWrapper = document.getElementById('item-page-wrapper')
|
|
|
|
if (itemPageWrapper) {
|
|
|
|
itemPageWrapper.removeEventListener('scroll', this.scroll)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filterSortChanged() {
|
|
|
|
this.init()
|
|
|
|
},
|
2024-01-05 21:38:29 +01:00
|
|
|
refresh() {
|
|
|
|
this.episodesCopy = this.episodes.map((ep) => ({ ...ep }))
|
|
|
|
this.init()
|
|
|
|
},
|
2022-05-25 01:38:25 +02:00
|
|
|
init() {
|
2023-12-31 21:51:01 +01:00
|
|
|
this.destroyEpisodeComponents()
|
|
|
|
this.totalEpisodes = this.episodesList.length
|
|
|
|
|
|
|
|
const lazyEpisodesTableEl = document.getElementById('lazy-episodes-table')
|
|
|
|
this.episodesTableOffsetTop = (lazyEpisodesTableEl?.offsetTop || 0) + 64
|
|
|
|
|
|
|
|
this.windowHeight = window.innerHeight
|
|
|
|
this.episodesPerPage = Math.ceil(this.windowHeight / this.episodeRowHeight)
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.mountEpisodes(0, Math.min(this.episodesPerPage, this.totalEpisodes))
|
|
|
|
})
|
2022-03-26 23:41:26 +01:00
|
|
|
}
|
|
|
|
},
|
2022-05-25 01:38:25 +02:00
|
|
|
mounted() {
|
2023-12-31 21:51:01 +01:00
|
|
|
this.episodesCopy = this.episodes.map((ep) => ({ ...ep }))
|
|
|
|
this.initListeners()
|
2022-05-25 01:38:25 +02:00
|
|
|
this.init()
|
2023-12-31 21:51:01 +01:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.removeListeners()
|
2022-05-25 01:38:25 +02:00
|
|
|
}
|
2022-03-26 23:41:26 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.episode-item {
|
|
|
|
transition: all 0.4s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.episode-enter-from,
|
|
|
|
.episode-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(30px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.episode-leave-active {
|
|
|
|
position: absolute;
|
|
|
|
}
|
2023-02-19 21:48:39 +01:00
|
|
|
</style>
|