From b1bf68b8cda204f7ce5c3e63862efbad4fffd167 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 21 May 2023 10:25:10 -0500 Subject: [PATCH] Add:Series progress to series cards #410 --- components/cards/LazySeriesCard.vue | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/cards/LazySeriesCard.vue b/components/cards/LazySeriesCard.vue index 7fdd4548..7ca5076c 100644 --- a/components/cards/LazySeriesCard.vue +++ b/components/cards/LazySeriesCard.vue @@ -5,6 +5,8 @@ +
+

{{ title }}

@@ -53,6 +55,27 @@ export default { books() { return this.series ? this.series.books || [] : [] }, + seriesBookProgress() { + return this.books + .map((libraryItem) => { + return this.store.getters['user/getUserMediaProgress'](libraryItem.id) + }) + .filter((p) => !!p) + }, + seriesBooksFinished() { + return this.seriesBookProgress.filter((p) => p.isFinished) + }, + hasSeriesBookInProgress() { + return this.seriesBookProgress.some((p) => !p.isFinished && p.progress > 0) + }, + seriesPercentInProgress() { + let totalFinishedAndInProgress = this.seriesBooksFinished.length + if (this.hasSeriesBookInProgress) totalFinishedAndInProgress += 1 + return Math.min(1, Math.max(0, totalFinishedAndInProgress / this.books.length)) + }, + isSeriesFinished() { + return this.books.length === this.seriesBooksFinished.length + }, store() { return this.$store || this.$nuxt.$store },