mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-07 16:44:16 +01:00
Update:Remove sort index from podcast episodes
This commit is contained in:
parent
d5da4441cd
commit
daa8c4cd67
@ -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 }}
|
||||||
|
@ -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++)
|
||||||
|
@ -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) {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user