From 578b877c0c78ce2468ad5413c8189f24bac2cb17 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:00:41 +0100 Subject: [PATCH] first draft --- .../components/stats/YearInReviewBanner.vue | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/client/components/stats/YearInReviewBanner.vue b/client/components/stats/YearInReviewBanner.vue index cf98d5cbb..2d6cd9c96 100644 --- a/client/components/stats/YearInReviewBanner.vue +++ b/client/components/stats/YearInReviewBanner.vue @@ -30,6 +30,9 @@

{{ yearInReviewVariant + 1 }}

+ + + @@ -66,6 +69,8 @@

{{ yearInReviewServerVariant + 1 }}

+ + @@ -113,15 +118,39 @@ export default { this.$refs.yearInReviewShort.share() }, refreshYearInReviewServer() { - this.$refs.yearInReviewServer.refresh() + if (this.$refs.yearInReviewServer != null) { + this.$refs.yearInReviewServer.refresh() + } }, refreshYearInReview() { - this.$refs.yearInReview.refresh() - this.$refs.yearInReviewShort.refresh() + if(this.$refs.yearInReview != null && this.$refs.yearInReviewShort != null) { + this.$refs.yearInReview.refresh() + this.$refs.yearInReviewShort.refresh() + } }, clickShowYearInReview() { this.showYearInReview = !this.showYearInReview - } + }, + eventOptions() { + if(this.$store.getters['libraries/getCurrentLibrary']) { + const oldestDate = this.$store.getters['libraries/getCurrentLibrary'].createdAt + if (oldestDate) { + const date = new Date(oldestDate) + const oldestYear = date.getFullYear() + const currentYear = new Date().getFullYear() + + const years = [] + for (let year = oldestYear; year <= currentYear; year++) { + years.push({ value: year, text: year.toString() }) + } + + return years + } + } else { + const currentYear = new Date().getFullYear(); + return [{ value: currentYear, text: currentYear.toString() }] + } + }, }, beforeMount() { this.yearInReviewYear = new Date().getFullYear() @@ -136,6 +165,14 @@ export default { } else { console.warn('Navigator.share not supported') } - } + }, + watch: { + yearInReviewYear(newYear, oldYear) { + this.$nextTick(() => { + this.refreshYearInReview() + this.refreshYearInReviewServer() + }); + }, + }, }