diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-06-22 14:01:36 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-06-22 14:01:36 +0000 |
| commit | 947f69a9531a7d99e79df3fc05f5e795de717dc6 (patch) | |
| tree | 390f69b8a2d09633b38d570c7b5ce34fee7c1ea7 /src/components/poll/poll.js | |
| parent | c2b48c32a260485e3ad623ce66eb6443f600e156 (diff) | |
Fix: problems with polls state
Diffstat (limited to 'src/components/poll/poll.js')
| -rw-r--r-- | src/components/poll/poll.js | 12 |
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 |
