mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-04 01:09:40 +00:00
Update:Remove sort index from podcast episodes
This commit is contained in:
parent
d5da4441cd
commit
daa8c4cd67
4 changed files with 8 additions and 27 deletions
|
|
@ -50,7 +50,7 @@ class PodcastManager {
|
|||
}
|
||||
|
||||
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) {
|
||||
const newPe = new PodcastEpisode()
|
||||
newPe.setData(ep, index++)
|
||||
|
|
|
|||
|
|
@ -285,7 +285,6 @@ class Podcast {
|
|||
|
||||
addPodcastEpisode(podcastEpisode) {
|
||||
this.episodes.push(podcastEpisode)
|
||||
this.reorderEpisodes()
|
||||
}
|
||||
|
||||
addNewEpisodeFromAudioFile(audioFile, index) {
|
||||
|
|
@ -297,19 +296,6 @@ class Podcast {
|
|||
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) {
|
||||
const episode = this.episodes.find(ep => ep.id === episodeId)
|
||||
if (episode) {
|
||||
|
|
|
|||
|
|
@ -278,11 +278,10 @@ class MediaFileScanner {
|
|||
const existingAudioFiles = mediaScanResult.audioFiles.filter(af => libraryItem.media.findFileWithInode(af.ino))
|
||||
|
||||
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) => {
|
||||
libraryItem.media.addNewEpisodeFromAudioFile(newAudioFile, newIndex++)
|
||||
})
|
||||
libraryItem.media.reorderEpisodes()
|
||||
hasUpdated = true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue