biome format --write
This commit is contained in:
parent
8372348148
commit
9262e803ec
415 changed files with 54076 additions and 17419 deletions
|
|
@ -5,10 +5,10 @@ export const usePollsStore = defineStore('polls', {
|
|||
state: () => ({
|
||||
// Contains key = id, value = number of trackers for this poll
|
||||
trackedPolls: {},
|
||||
pollsObject: {}
|
||||
pollsObject: {},
|
||||
}),
|
||||
actions: {
|
||||
mergeOrAddPoll (poll) {
|
||||
mergeOrAddPoll(poll) {
|
||||
const existingPoll = this.pollsObject[poll.id]
|
||||
// Make expired-state change trigger re-renders properly
|
||||
poll.expired = Date.now() > Date.parse(poll.expires_at)
|
||||
|
|
@ -18,17 +18,19 @@ export const usePollsStore = defineStore('polls', {
|
|||
this.pollsObject[poll.id] = poll
|
||||
}
|
||||
},
|
||||
updateTrackedPoll (pollId) {
|
||||
window.vuex.state.api.backendInteractor.fetchPoll({ pollId }).then(poll => {
|
||||
setTimeout(() => {
|
||||
if (this.trackedPolls[pollId]) {
|
||||
this.updateTrackedPoll(pollId)
|
||||
}
|
||||
}, 30 * 1000)
|
||||
this.mergeOrAddPoll(poll)
|
||||
})
|
||||
updateTrackedPoll(pollId) {
|
||||
window.vuex.state.api.backendInteractor
|
||||
.fetchPoll({ pollId })
|
||||
.then((poll) => {
|
||||
setTimeout(() => {
|
||||
if (this.trackedPolls[pollId]) {
|
||||
this.updateTrackedPoll(pollId)
|
||||
}
|
||||
}, 30 * 1000)
|
||||
this.mergeOrAddPoll(poll)
|
||||
})
|
||||
},
|
||||
trackPoll (pollId) {
|
||||
trackPoll(pollId) {
|
||||
if (!this.trackedPolls[pollId]) {
|
||||
setTimeout(() => this.updateTrackedPoll(pollId), 30 * 1000)
|
||||
}
|
||||
|
|
@ -39,7 +41,7 @@ export const usePollsStore = defineStore('polls', {
|
|||
this.trackedPolls[pollId] = 1
|
||||
}
|
||||
},
|
||||
untrackPoll (pollId) {
|
||||
untrackPoll(pollId) {
|
||||
const currentValue = this.trackedPolls[pollId]
|
||||
if (currentValue) {
|
||||
this.trackedPolls[pollId] = currentValue - 1
|
||||
|
|
@ -47,11 +49,13 @@ export const usePollsStore = defineStore('polls', {
|
|||
this.trackedPolls[pollId] = 0
|
||||
}
|
||||
},
|
||||
votePoll ({ pollId, choices }) {
|
||||
return window.vuex.state.api.backendInteractor.vote({ pollId, choices }).then(poll => {
|
||||
this.mergeOrAddPoll(poll)
|
||||
return poll
|
||||
})
|
||||
}
|
||||
}
|
||||
votePoll({ pollId, choices }) {
|
||||
return window.vuex.state.api.backendInteractor
|
||||
.vote({ pollId, choices })
|
||||
.then((poll) => {
|
||||
this.mergeOrAddPoll(poll)
|
||||
return poll
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue