Update:Sort local books shelf show unfinished books first #302

This commit is contained in:
advplyr
2022-08-07 11:00:35 -05:00
parent 4a82ba7c86
commit b78f004f29
+9 -1
View File
@@ -56,6 +56,9 @@ export default {
}, },
altViewEnabled() { altViewEnabled() {
return this.$store.getters['getAltViewEnabled'] return this.$store.getters['getAltViewEnabled']
},
localMediaProgress() {
return this.$store.state.globals.localMediaProgress
} }
}, },
methods: { methods: {
@@ -69,6 +72,7 @@ export default {
var podcasts = [] var podcasts = []
localMedia.forEach((item) => { localMedia.forEach((item) => {
if (item.mediaType == 'book') { if (item.mediaType == 'book') {
item.progress = this.localMediaProgress.find((lmp) => lmp.id === item.id)
books.push(item) books.push(item)
} else if (item.mediaType == 'podcast') { } else if (item.mediaType == 'podcast') {
podcasts.push(item) podcasts.push(item)
@@ -80,7 +84,11 @@ export default {
id: 'local-books', id: 'local-books',
label: 'Local Books', label: 'Local Books',
type: 'book', type: 'book',
entities: books entities: books.sort((a, b) => {
if (a.progress && a.progress.isFinished) return 1
else if (b.progress && b.progress.isFinished) return -1
return 0
})
}) })
} }
if (podcasts.length) { if (podcasts.length) {