diff options
Diffstat (limited to 'src/components/UploadVoter.vue')
| -rw-r--r-- | src/components/UploadVoter.vue | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/components/UploadVoter.vue b/src/components/UploadVoter.vue index e5d18ae..b929a45 100644 --- a/src/components/UploadVoter.vue +++ b/src/components/UploadVoter.vue @@ -45,16 +45,17 @@ }, computed: { myVote () { - if (!this.upload || !this.upload.voting || !Array.isArray(this.upload.voting.votes) || this.upload.voting.votes.length === 0) { - return undefined + if (!this.upload.voting.vote) { + let that = this + this.$http.get(`/uploads/${this.upload.id}/vote`).then((response) => { this.upload.voting.vote = response.data }) } - return this.upload.voting.votes[0] + return this.upload.voting.vote }, }, methods: { vote (impact) { let that = this - this.$http.post(`/uploads/${this.upload._id}/vote`, {impact: impact}).then(response => that.$emit('voted')) + this.$http.post(`/uploads/${this.upload.id}/vote`, {impact: impact}).then(response => that.$emit('voted')) }, }, } |
