mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe
synced 2025-05-06 21:29:13 +08:00
implements part of #178, other parts will come later Co-authored-by: Sol Fisher Romanoff <sol@solfisher.com> Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/186 Co-authored-by: sfr <sol@solfisher.com> Co-committed-by: sfr <sol@solfisher.com>
20 lines
748 B
JavaScript
20 lines
748 B
JavaScript
import apiService from '../api/api.service.js'
|
|
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
|
import { forEach } from 'lodash'
|
|
|
|
const fetchAndUpdate = ({ store, credentials, state, limit, page, pageSize }) => {
|
|
return apiService.getReports({ credentials, state, limit, page, pageSize })
|
|
.then(reports => forEach(reports, report => store.commit('setReport', { report })))
|
|
}
|
|
|
|
const startFetching = ({ store, credentials, state, limit, page, pageSize }) => {
|
|
const boundFetchAndUpdate = () => fetchAndUpdate({ store, credentials, state, limit, page, pageSize })
|
|
boundFetchAndUpdate()
|
|
return promiseInterval(boundFetchAndUpdate, 60000)
|
|
}
|
|
|
|
const reportsFetcher = {
|
|
startFetching
|
|
}
|
|
|
|
export default reportsFetcher
|