This commit is contained in:
Julien Cornebise 2026-05-10 17:35:18 +01:00 committed by GitHub
commit 0c3b743557
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,14 +194,18 @@ export default {
bValue = b[this.sortKey] bValue = b[this.sortKey]
} }
// Sort episodes with no pub date as the oldest // publishedAt is a numeric ms epoch (negative for pre-1970 broadcasts).
// Compare numerically so the leading "-" of negative epochs doesn't
// break Intl.Collator{numeric:true}, which only handles unsigned digit
// runs. Missing dates count as oldest.
if (this.sortKey === 'publishedAt') { if (this.sortKey === 'publishedAt') {
if (!aValue) aValue = Number.MAX_VALUE const av = aValue == null ? Number.NEGATIVE_INFINITY : Number(aValue)
if (!bValue) bValue = Number.MAX_VALUE const bv = bValue == null ? Number.NEGATIVE_INFINITY : Number(bValue)
return av < bv ? -1 : av > bv ? 1 : 0
} }
const primaryCompare = String(aValue).localeCompare(String(bValue), undefined, { numeric: true, sensitivity: 'base' }) const primaryCompare = String(aValue).localeCompare(String(bValue), undefined, { numeric: true, sensitivity: 'base' })
if (primaryCompare !== 0 || this.sortKey === 'publishedAt') return primaryCompare if (primaryCompare !== 0) return primaryCompare
// When sorting by season, secondary sort is by episode number // When sorting by season, secondary sort is by episode number
if (this.sortKey === 'season') { if (this.sortKey === 'season') {
@ -212,11 +216,10 @@ export default {
if (secondaryCompare !== 0) return secondaryCompare if (secondaryCompare !== 0) return secondaryCompare
} }
// Final sort by publishedAt // Final tiebreaker: numeric publishedAt
let aPubDate = a.publishedAt || Number.MAX_VALUE const apa = a.publishedAt == null ? Number.NEGATIVE_INFINITY : Number(a.publishedAt)
let bPubDate = b.publishedAt || Number.MAX_VALUE const bpa = b.publishedAt == null ? Number.NEGATIVE_INFINITY : Number(b.publishedAt)
return apa < bpa ? -1 : apa > bpa ? 1 : 0
return String(aPubDate).localeCompare(String(bPubDate), undefined, { numeric: true, sensitivity: 'base' })
}) })
}, },
episodesList() { episodesList() {