Fix:Podcast episode sort by published at

This commit is contained in:
advplyr 2022-09-03 08:31:37 -05:00
parent 3dc848a106
commit 0700f12896

View File

@ -228,6 +228,7 @@ class Podcast {
addPodcastEpisode(podcastEpisode) { addPodcastEpisode(podcastEpisode) {
this.episodes.push(podcastEpisode) this.episodes.push(podcastEpisode)
this.reorderEpisodes()
} }
addNewEpisodeFromAudioFile(audioFile, index) { addNewEpisodeFromAudioFile(audioFile, index) {
@ -241,15 +242,13 @@ class Podcast {
reorderEpisodes() { reorderEpisodes() {
var hasUpdates = false var hasUpdates = false
// TODO: Sort by published date this.episodes = naturalSort(this.episodes).desc((ep) => ep.publishedAt)
this.episodes = naturalSort(this.episodes).asc((ep) => ep.bestFilename)
for (let i = 0; i < this.episodes.length; i++) { for (let i = 0; i < this.episodes.length; i++) {
if (this.episodes[i].index !== (i + 1)) { if (this.episodes[i].index !== (i + 1)) {
this.episodes[i].index = i + 1 this.episodes[i].index = i + 1
hasUpdates = true hasUpdates = true
} }
} }
this.episodes.sort((a, b) => b.index - a.index)
return hasUpdates return hasUpdates
} }