From df5a54c7b1f862c3425d7aa30e0a8b964e7b9716 Mon Sep 17 00:00:00 2001
From: Arne Schauf <git@asw.io>
Date: Sun, 4 Mar 2018 03:12:03 +0100
Subject: lots of cool features!

---
 src/components/UploadVoter.vue | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'src/components/UploadVoter.vue')

diff --git a/src/components/UploadVoter.vue b/src/components/UploadVoter.vue
index 65a5453..563bc79 100644
--- a/src/components/UploadVoter.vue
+++ b/src/components/UploadVoter.vue
@@ -7,10 +7,11 @@
         </i>
         {{ upload.voting.sum }}
       </h5>
-      <span v-if="upload.author.username !== $store.state.user.decodedToken.username">
+      <span v-if="upload.author.username !== $store.state.user.decodedToken.username && !myVote">
         <q-btn color="negative" round small icon="fa-thumbs-down" @click="vote(-1)"></q-btn>
         <q-btn color="positive" round small icon="fa-thumbs-up" @click="vote(1)"></q-btn>
       </span>
+      <span v-if="myVote">You voted <i :class="`fas fa-thumbs-${myVote.impact === 1 ? 'up text-positive' : 'down text-negative'}`"></i></span>
     </div>
     <div class="group" v-else>
       <i class="fa"
@@ -37,6 +38,14 @@
     data () {
       return {}
     },
+    computed: {
+      myVote () {
+        if (!this.upload || !this.upload.voting || !Array.isArray(this.upload.voting.votes) || this.upload.voting.votes.length === 0) {
+          return undefined
+        }
+        return this.upload.voting.votes[0]
+      },
+    },
     methods: {
       vote (impact) {
         let that = this
-- 
cgit v1.2.3-54-g00ecf

