migrate follow requests to separate pinia store
This commit is contained in:
parent
d8825bae33
commit
8a743c648c
17 changed files with 121 additions and 99 deletions
|
|
@ -1,33 +0,0 @@
|
|||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
import { fetchFollowRequests } from 'src/api/user.js'
|
||||
import { promiseInterval } from 'src/services/promise_interval/promise_interval.js'
|
||||
|
||||
const fetchAndUpdate = ({ store, credentials }) => {
|
||||
return fetchFollowRequests({ credentials })
|
||||
.then(
|
||||
(result) => {
|
||||
const { data: requests } = result
|
||||
store.commit('setFollowRequests', requests)
|
||||
useUsersStore().addNewUsers(result)
|
||||
},
|
||||
(rej) => {
|
||||
console.error(rej)
|
||||
},
|
||||
)
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
})
|
||||
}
|
||||
|
||||
const startFetching = ({ credentials, store }) => {
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||
boundFetchAndUpdate()
|
||||
return promiseInterval(boundFetchAndUpdate, 10000)
|
||||
}
|
||||
|
||||
const followRequestFetcher = {
|
||||
startFetching,
|
||||
}
|
||||
|
||||
export default followRequestFetcher
|
||||
Loading…
Add table
Add a link
Reference in a new issue