aboutsummaryrefslogtreecommitdiff
path: root/src/components/poll/poll.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/poll/poll.js')
-rw-r--r--src/components/poll/poll.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/components/poll/poll.js b/src/components/poll/poll.js
index 9988070e..98db5582 100644
--- a/src/components/poll/poll.js
+++ b/src/components/poll/poll.js
@@ -3,7 +3,7 @@ import { forEach, map } from 'lodash'
export default {
name: 'Poll',
- props: ['pollId'],
+ props: ['basePoll'],
components: { Timeago },
data () {
return {
@@ -11,13 +11,19 @@ export default {
choices: []
}
},
- mounted () {
+ created () {
+ if (!this.$store.state.polls.pollsObject[this.pollId]) {
+ this.$store.dispatch('mergeOrAddPoll', this.basePoll)
+ }
this.$store.dispatch('trackPoll', this.pollId)
},
destroyed () {
this.$store.dispatch('untrackPoll', this.pollId)
},
computed: {
+ pollId () {
+ return this.basePoll.id
+ },
poll () {
const storePoll = this.$store.state.polls.pollsObject[this.pollId]
return storePoll || {}
@@ -29,7 +35,7 @@ export default {
return (this.poll && this.poll.expires_at) || 0
},
expired () {
- return Date.now() > Date.parse(this.expiresAt)
+ return (this.poll && this.poll.expired) || false
},
loggedIn () {
return this.$store.state.users.currentUser