Update:Remove sort index from podcast episodes

This commit is contained in:
advplyr 2023-07-22 09:24:46 -05:00
parent d5da4441cd
commit daa8c4cd67
4 changed files with 8 additions and 27 deletions

View File

@ -20,18 +20,14 @@
<div v-if="!episodes.length" class="flex my-4 text-center justify-center text-xl">{{ $strings.MessageNoEpisodes }}</div> <div v-if="!episodes.length" class="flex my-4 text-center justify-center text-xl">{{ $strings.MessageNoEpisodes }}</div>
<table v-else class="text-sm tracksTable"> <table v-else class="text-sm tracksTable">
<tr> <tr>
<th class="text-left">Sort #</th> <th class="text-center w-20 min-w-20">{{ $strings.LabelEpisode }}</th>
<th class="text-left whitespace-nowrap">{{ $strings.LabelEpisode }}</th> <th class="text-left">{{ $strings.LabelEpisodeTitle }}</th>
<th class="text-left">{{ $strings.EpisodeTitle }}</th> <th class="text-center w-28">{{ $strings.LabelEpisodeDuration }}</th>
<th class="text-center w-28">{{ $strings.EpisodeDuration }}</th> <th class="text-center w-28">{{ $strings.LabelEpisodeSize }}</th>
<th class="text-center w-28">{{ $strings.EpisodeSize }}</th>
</tr> </tr>
<tr v-for="episode in episodes" :key="episode.id"> <tr v-for="episode in episodes" :key="episode.id">
<td class="text-left"> <td class="text-center w-20 min-w-20">
<p class="px-4">{{ episode.index }}</p> <p>{{ episode.episode }}</p>
</td>
<td class="text-left">
<p class="px-4">{{ episode.episode }}</p>
</td> </td>
<td> <td>
{{ episode.title }} {{ episode.title }}

View File

@ -50,7 +50,7 @@ class PodcastManager {
} }
async downloadPodcastEpisodes(libraryItem, episodesToDownload, isAutoDownload) { async downloadPodcastEpisodes(libraryItem, episodesToDownload, isAutoDownload) {
let index = libraryItem.media.episodes.length + 1 let index = Math.max(...libraryItem.media.episodes.filter(ep => ep.index == null || isNaN(ep.index)).map(ep => Number(ep.index))) + 1
for (const ep of episodesToDownload) { for (const ep of episodesToDownload) {
const newPe = new PodcastEpisode() const newPe = new PodcastEpisode()
newPe.setData(ep, index++) newPe.setData(ep, index++)

View File

@ -285,7 +285,6 @@ class Podcast {
addPodcastEpisode(podcastEpisode) { addPodcastEpisode(podcastEpisode) {
this.episodes.push(podcastEpisode) this.episodes.push(podcastEpisode)
this.reorderEpisodes()
} }
addNewEpisodeFromAudioFile(audioFile, index) { addNewEpisodeFromAudioFile(audioFile, index) {
@ -297,19 +296,6 @@ class Podcast {
this.episodes.push(pe) this.episodes.push(pe)
} }
reorderEpisodes() {
var hasUpdates = false
this.episodes = naturalSort(this.episodes).desc((ep) => ep.publishedAt)
for (let i = 0; i < this.episodes.length; i++) {
if (this.episodes[i].index !== (i + 1)) {
this.episodes[i].index = i + 1
hasUpdates = true
}
}
return hasUpdates
}
removeEpisode(episodeId) { removeEpisode(episodeId) {
const episode = this.episodes.find(ep => ep.id === episodeId) const episode = this.episodes.find(ep => ep.id === episodeId)
if (episode) { if (episode) {

View File

@ -278,11 +278,10 @@ class MediaFileScanner {
const existingAudioFiles = mediaScanResult.audioFiles.filter(af => libraryItem.media.findFileWithInode(af.ino)) const existingAudioFiles = mediaScanResult.audioFiles.filter(af => libraryItem.media.findFileWithInode(af.ino))
if (newAudioFiles.length) { if (newAudioFiles.length) {
let newIndex = libraryItem.media.episodes.length + 1 let newIndex = Math.max(...libraryItem.media.episodes.filter(ep => ep.index == null || isNaN(ep.index)).map(ep => Number(ep.index))) + 1
newAudioFiles.forEach((newAudioFile) => { newAudioFiles.forEach((newAudioFile) => {
libraryItem.media.addNewEpisodeFromAudioFile(newAudioFile, newIndex++) libraryItem.media.addNewEpisodeFromAudioFile(newAudioFile, newIndex++)
}) })
libraryItem.media.reorderEpisodes()
hasUpdated = true hasUpdated = true
} }