Merge pull request #4030 from 4ch1m/add_filename_sorting_for_podcasts-view

new sort option for podcasts view (-> sort by filename)
This commit is contained in:
advplyr 2025-02-28 17:45:43 -06:00 committed by GitHub
commit 43a507faa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View file

@ -1,3 +1,4 @@
<template>
<div id="lazy-episodes-table" class="w-full py-6">
<div class="flex flex-wrap flex-col md:flex-row md:items-center mb-4">
@ -123,6 +124,10 @@ export default {
{
text: this.$strings.LabelEpisode,
value: 'episode'
},
{
text: this.$strings.LabelFilename,
value: 'audioFile.metadata.filename'
}
]
},
@ -171,8 +176,17 @@ export default {
return episodeProgress && !episodeProgress.isFinished
})
.sort((a, b) => {
let aValue = a[this.sortKey]
let bValue = b[this.sortKey]
let aValue
let bValue
if (this.sortKey.includes('.')) {
const getNestedValue = (ob, s) => s.split('.').reduce((o, k) => o?.[k], ob)
aValue = getNestedValue(a, this.sortKey)
bValue = getNestedValue(b, this.sortKey)
} else {
aValue = a[this.sortKey]
bValue = b[this.sortKey]
}
// Sort episodes with no pub date as the oldest
if (this.sortKey === 'publishedAt') {
@ -440,7 +454,8 @@ export default {
propsData: {
index,
libraryItemId: this.libraryItem.id,
episode: this.episodesList[index]
episode: this.episodesList[index],
sortKey: this.sortKey
},
created() {
this.$on('selected', (payload) => {