No Episodes
@@ -32,6 +35,7 @@ export default { data() { return { episodesCopy: [], + filterKey: 'incomplete', sortKey: 'publishedAt', sortDesc: true, selectedEpisode: null, @@ -63,12 +67,20 @@ export default { return this.media.episodes || [] }, episodesSorted() { - return this.episodesCopy.sort((a, b) => { - if (this.sortDesc) { - return String(b[this.sortKey]).localeCompare(String(a[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' }) - } - return String(a[this.sortKey]).localeCompare(String(b[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' }) - }) + return this.episodesCopy + .filter((ep) => { + if (this.filterKey === 'all') return true + const episodeProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, ep.id) + if (this.filterKey === 'incomplete') return !episodeProgress || !episodeProgress.isFinished + if (this.filterKey === 'complete') return episodeProgress && episodeProgress.isFinished + return episodeProgress && !episodeProgress.isFinished + }) + .sort((a, b) => { + if (this.sortDesc) { + return String(b[this.sortKey]).localeCompare(String(a[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' }) + } + return String(a[this.sortKey]).localeCompare(String(b[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' }) + }) }, selectedIsFinished() { // Find an item that is not finished, if none then all items finished