diff --git a/src/components/VinlottisPage.vue b/src/components/VinlottisPage.vue index b608cb3..aafebcb 100644 --- a/src/components/VinlottisPage.vue +++ b/src/components/VinlottisPage.vue @@ -81,14 +81,9 @@ export default { !this.pushAllowed || localStorage.getItem("push") == null ); - }, - todayExists: () => { - return prelottery() - .then(wines => wines.length > 0) - .catch(() => false) } }, - mounted() { + async mounted() { this.$on("push-allowed", () => { this.pushAllowed = true; }); @@ -96,6 +91,11 @@ export default { return; } this.track(); + try { + this.todayExists = (await prelottery()).length > 0; + } catch (e) { + this.todayExists = false; + } }, methods: { requestNotificationAccess() { diff --git a/src/components/VirtualLotteryPage.vue b/src/components/VirtualLotteryPage.vue index 257cb4e..531e588 100644 --- a/src/components/VirtualLotteryPage.vue +++ b/src/components/VirtualLotteryPage.vue @@ -8,9 +8,7 @@ attendeesFetched && winnersFetched " - > - Her var det lite.. Sikker på at det er en virtuell trekning nå? - + >Her var det lite.. Sikker på at det er en virtuell trekning nå?

Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri

Send gjerne melding om fargeønsker også

@@ -21,15 +19,11 @@ Se her -
+

Live oversikt av lodd kjøp i dag

-
+

{{ ticketsBought[color] }} kjøpt

@@ -88,8 +82,7 @@ export default { }; }, created() { - getChatHistory() - .then(messages => this.chatHistory = messages) + getChatHistory().then(messages => (this.chatHistory = messages)); }, mounted() { this.track(); @@ -150,7 +143,7 @@ export default { todayExists: () => { return prelottery() .then(wines => wines.length > 0) - .catch(() => false) + .catch(() => false); } }, methods: { @@ -176,14 +169,19 @@ export default { let response = await attendees(); if (response) { this.attendees = response; - const addValueOfListObjectByKey = (list, key) => list.map(object => object[key]).reduce((a, b) => a + b); + if (this.attendees == undefined || this.attendees.length == 0) { + this.attendeesFetched = true; + return; + } + const addValueOfListObjectByKey = (list, key) => + list.map(object => object[key]).reduce((a, b) => a + b); this.ticketsBought = { red: addValueOfListObjectByKey(response, "red"), blue: addValueOfListObjectByKey(response, "blue"), green: addValueOfListObjectByKey(response, "green"), - yellow: addValueOfListObjectByKey(response, "yellow"), - } + yellow: addValueOfListObjectByKey(response, "yellow") + }; } this.attendeesFetched = true; },