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

@ -10,8 +10,13 @@
<div class="h-10 flex items-center mt-1.5 mb-0.5 overflow-hidden">
<p class="text-sm text-gray-200 line-clamp-2" v-html="episodeSubtitle"></p>
</div>
<div class="h-8 flex items-center">
<div class="w-full inline-flex justify-between max-w-xl">
<p v-if="sortKey === 'audioFile.metadata.filename'" class="text-sm text-gray-300 truncate font-light">
<strong className="font-bold">{{ $strings.LabelFilename }}</strong
>: {{ episode.audioFile.metadata.filename }}
</p>
<div v-else class="w-full inline-flex justify-between max-w-xl">
<p v-if="episode?.season" class="text-sm text-gray-300">{{ $getString('LabelSeasonNumber', [episode.season]) }}</p>
<p v-if="episode?.episode" class="text-sm text-gray-300">{{ $getString('LabelEpisodeNumber', [episode.episode]) }}</p>
<p v-if="episode?.chapters?.length" class="text-sm text-gray-300">{{ $getString('LabelChapterCount', [episode.chapters.length]) }}</p>
@ -65,7 +70,8 @@ export default {
episode: {
type: Object,
default: () => null
}
},
sortKey: String
},
data() {
return {

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) => {