remaining backend interactor removals
This commit is contained in:
parent
28efd7ebd2
commit
0d9709825f
45 changed files with 1118 additions and 856 deletions
|
|
@ -1,6 +1,10 @@
|
|||
import { merge } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
|
||||
import { fetchPoll, vote } from 'src/services/api/api.service.js'
|
||||
|
||||
export const usePollsStore = defineStore('polls', {
|
||||
state: () => ({
|
||||
// Contains key = id, value = number of trackers for this poll
|
||||
|
|
@ -19,16 +23,17 @@ export const usePollsStore = defineStore('polls', {
|
|||
}
|
||||
},
|
||||
updateTrackedPoll(pollId) {
|
||||
window.vuex.state.api.backendInteractor
|
||||
.fetchPoll({ pollId })
|
||||
.then((poll) => {
|
||||
setTimeout(() => {
|
||||
if (this.trackedPolls[pollId]) {
|
||||
this.updateTrackedPoll(pollId)
|
||||
}
|
||||
}, 30 * 1000)
|
||||
this.mergeOrAddPoll(poll)
|
||||
})
|
||||
fetchPoll({
|
||||
pollId,
|
||||
credentials: useCredentialsStore().current,
|
||||
}).then((poll) => {
|
||||
setTimeout(() => {
|
||||
if (this.trackedPolls[pollId]) {
|
||||
this.updateTrackedPoll(pollId)
|
||||
}
|
||||
}, 30 * 1000)
|
||||
this.mergeOrAddPoll(poll)
|
||||
})
|
||||
},
|
||||
trackPoll(pollId) {
|
||||
if (!this.trackedPolls[pollId]) {
|
||||
|
|
@ -50,12 +55,14 @@ export const usePollsStore = defineStore('polls', {
|
|||
}
|
||||
},
|
||||
votePoll({ pollId, choices }) {
|
||||
return window.vuex.state.api.backendInteractor
|
||||
.vote({ pollId, choices })
|
||||
.then((poll) => {
|
||||
this.mergeOrAddPoll(poll)
|
||||
return poll
|
||||
})
|
||||
return vote({
|
||||
pollId,
|
||||
choices,
|
||||
credentials: useCredentialsStore().current,
|
||||
}).then((poll) => {
|
||||
this.mergeOrAddPoll(poll)
|
||||
return poll
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue