akkoma-fe/src/services/backend_interactor_service/backend_interactor_service.js

63 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-12-08 17:18:38 +00:00
import apiService, { getMastodonSocketURI, ProcessedWS } from '../api/api.service.js'
import timelineFetcher from '../timeline_fetcher/timeline_fetcher.service.js'
2019-04-03 16:04:46 +00:00
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
2022-06-15 15:34:11 +00:00
import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
import announcementsFetcher from '../../services/announcements_fetcher/announcements_fetcher.service.js'
import configFetcher from '../config_fetcher/config_fetcher.service.js'
import reportsFetcher from '../reports_fetcher/reports_fetcher.service.js'
const backendInteractorService = credentials => ({
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
return timelineFetcher.startFetching({ timeline, store, credentials, userId, listId, tag })
},
fetchTimeline (args) {
return timelineFetcher.fetchAndUpdate({ ...args, credentials })
},
2019-04-04 16:03:56 +00:00
startFetchingNotifications ({ store }) {
2019-04-04 16:03:56 +00:00
return notificationsFetcher.startFetching({ store, credentials })
},
startFetchingConfig ({ store }) {
return configFetcher.startFetching({ store, credentials })
},
fetchNotifications (args) {
return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
},
2019-05-08 03:36:35 +00:00
2022-06-15 15:34:11 +00:00
startFetchingLists ({ store }) {
return listsFetcher.startFetching({ store, credentials })
},
startFetchingAnnouncements ({ store }) {
return announcementsFetcher.startFetching({ store, credentials })
},
startFetchingReports ({ store, state, limit, page, pageSize }) {
return reportsFetcher.startFetching({ store, credentials, state, limit, page, pageSize })
},
2019-12-08 17:18:38 +00:00
startUserSocket ({ store }) {
const serv = store.rootState.instance.server.replace('http', 'ws')
2019-11-24 16:50:28 +00:00
const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
2019-12-08 17:18:38 +00:00
return ProcessedWS({ url, id: 'User' })
2019-11-24 16:50:28 +00:00
},
2022-08-30 13:37:36 +00:00
getSupportedTranslationlanguages ({ store }) {
return apiService.getSupportedTranslationlanguages({ store, credentials })
},
...Object.entries(apiService).reduce((acc, [key, func]) => {
return {
...acc,
[key]: (args) => func({ credentials, ...args })
}
}, {}),
verifyCredentials: apiService.verifyCredentials
})
export default backendInteractorService