Refetch reports every 60 seconds
This commit is contained in:
parent
405a60d249
commit
bdd970ca68
6 changed files with 40 additions and 7 deletions
|
@ -396,6 +396,7 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
// Start fetching things that don't need to block the UI
|
// Start fetching things that don't need to block the UI
|
||||||
store.dispatch('fetchMutes')
|
store.dispatch('fetchMutes')
|
||||||
store.dispatch('startFetchingAnnouncements')
|
store.dispatch('startFetchingAnnouncements')
|
||||||
|
store.dispatch('startFetchingReports')
|
||||||
getTOS({ store })
|
getTOS({ store })
|
||||||
getStickers({ store })
|
getStickers({ store })
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,6 @@ const ReportsTab = {
|
||||||
showClosed: false
|
showClosed: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
|
||||||
this.$store.dispatch('getReports')
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
ReportCard
|
ReportCard
|
||||||
|
|
|
@ -163,6 +163,7 @@ const api = {
|
||||||
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
||||||
dispatch('startFetchingNotifications')
|
dispatch('startFetchingNotifications')
|
||||||
dispatch('startFetchingAnnouncements')
|
dispatch('startFetchingAnnouncements')
|
||||||
|
dispatch('startFetchingReports')
|
||||||
dispatch('pushGlobalNotice', {
|
dispatch('pushGlobalNotice', {
|
||||||
level: 'error',
|
level: 'error',
|
||||||
messageKey: 'timeline.socket_broke',
|
messageKey: 'timeline.socket_broke',
|
||||||
|
@ -280,6 +281,19 @@ const api = {
|
||||||
if (!fetcher) return
|
if (!fetcher) return
|
||||||
store.commit('removeFetcher', { fetcherName: 'announcements', fetcher })
|
store.commit('removeFetcher', { fetcherName: 'announcements', fetcher })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Reports
|
||||||
|
startFetchingReports (store) {
|
||||||
|
if (store.state.fetchers['reports']) return
|
||||||
|
const fetcher = store.state.backendInteractor.startFetchingReports({ store })
|
||||||
|
store.commit('addFetcher', { fetcherName: 'reports', fetcher })
|
||||||
|
},
|
||||||
|
stopFetchingReports (store) {
|
||||||
|
const fetcher = store.state.fetchers.reports
|
||||||
|
if (!fetcher) return
|
||||||
|
store.commit('removeFetcher', { fetcherName: 'reports', fetcher })
|
||||||
|
},
|
||||||
|
|
||||||
getSupportedTranslationlanguages (store) {
|
getSupportedTranslationlanguages (store) {
|
||||||
store.state.backendInteractor.getSupportedTranslationlanguages({ store })
|
store.state.backendInteractor.getSupportedTranslationlanguages({ store })
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
|
|
@ -70,10 +70,6 @@ const reports = {
|
||||||
closeUserReportingModal ({ commit }) {
|
closeUserReportingModal ({ commit }) {
|
||||||
commit('closeUserReportingModal')
|
commit('closeUserReportingModal')
|
||||||
},
|
},
|
||||||
getReports ({ rootState, commit }, params) {
|
|
||||||
return rootState.api.backendInteractor.getReports(params)
|
|
||||||
.then(reports => forEach(reports, report => commit('setReport', { report })))
|
|
||||||
},
|
|
||||||
updateReportStates ({ rootState, commit }, { reports }) {
|
updateReportStates ({ rootState, commit }, { reports }) {
|
||||||
commit('updateReportStates', { reports })
|
commit('updateReportStates', { reports })
|
||||||
return rootState.api.backendInteractor.updateReportStates({ reports })
|
return rootState.api.backendInteractor.updateReportStates({ reports })
|
||||||
|
|
|
@ -5,6 +5,7 @@ import followRequestFetcher from '../../services/follow_request_fetcher/follow_r
|
||||||
import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
|
import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
|
||||||
import announcementsFetcher from '../../services/announcements_fetcher/announcements_fetcher.service.js'
|
import announcementsFetcher from '../../services/announcements_fetcher/announcements_fetcher.service.js'
|
||||||
import configFetcher from '../config_fetcher/config_fetcher.service.js'
|
import configFetcher from '../config_fetcher/config_fetcher.service.js'
|
||||||
|
import reportsFetcher from '../reports_fetcher/reports_fetcher.service.js'
|
||||||
|
|
||||||
const backendInteractorService = credentials => ({
|
const backendInteractorService = credentials => ({
|
||||||
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
|
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
|
||||||
|
@ -39,6 +40,10 @@ const backendInteractorService = credentials => ({
|
||||||
return announcementsFetcher.startFetching({ store, credentials })
|
return announcementsFetcher.startFetching({ store, credentials })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startFetchingReports ({ store, state, limit, page, pageSize }) {
|
||||||
|
return reportsFetcher.startFetching({ store, credentials, state, limit, page, pageSize })
|
||||||
|
},
|
||||||
|
|
||||||
startUserSocket ({ store }) {
|
startUserSocket ({ store }) {
|
||||||
const serv = store.rootState.instance.server.replace('http', 'ws')
|
const serv = store.rootState.instance.server.replace('http', 'ws')
|
||||||
const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
|
const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
|
||||||
|
|
20
src/services/reports_fetcher/reports_fetcher.service.js
Normal file
20
src/services/reports_fetcher/reports_fetcher.service.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
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
|
Loading…
Reference in a new issue