Update:Episodes table sort by pub date treats episodes with no pub date as the oldest #1454

This commit is contained in:
advplyr 2023-04-09 17:20:56 -05:00
parent 718890cfad
commit 77cc0934be

View File

@ -54,7 +54,7 @@ export default {
quickMatchingEpisodes: false, quickMatchingEpisodes: false,
search: null, search: null,
searchTimeout: null, searchTimeout: null,
searchText: null, searchText: null
} }
}, },
watch: { watch: {
@ -139,19 +139,25 @@ export default {
return episodeProgress && !episodeProgress.isFinished return episodeProgress && !episodeProgress.isFinished
}) })
.sort((a, b) => { .sort((a, b) => {
if (this.sortDesc) { let aValue = a[this.sortKey]
return String(b[this.sortKey]).localeCompare(String(a[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' }) 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
} }
return String(a[this.sortKey]).localeCompare(String(b[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' })
if (this.sortDesc) {
return String(bValue).localeCompare(String(aValue), undefined, { numeric: true, sensitivity: 'base' })
}
return String(aValue).localeCompare(String(bValue), undefined, { numeric: true, sensitivity: 'base' })
}) })
}, },
episodesList() { episodesList() {
return this.episodesSorted.filter((episode) => { return this.episodesSorted.filter((episode) => {
if (!this.searchText) return true if (!this.searchText) return true
return ( return (episode.title && episode.title.toLowerCase().includes(this.searchText)) || (episode.subtitle && episode.subtitle.toLowerCase().includes(this.searchText))
(episode.title && episode.title.toLowerCase().includes(this.searchText)) ||
(episode.subtitle && episode.subtitle.toLowerCase().includes(this.searchText))
)
}) })
}, },
selectedIsFinished() { selectedIsFinished() {