setting-sync (#175)
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk> Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/175
This commit is contained in:
parent
eaf2bd05a0
commit
4f837f75ea
15 changed files with 314 additions and 16 deletions
|
@ -102,6 +102,8 @@ const PLEROMA_ANNOUNCEMENTS_URL = '/api/v1/pleroma/admin/announcements'
|
|||
const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements'
|
||||
const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
|
||||
const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
|
||||
const AKKOMA_SETTING_PROFILE_URL = (name) => `/api/v1/akkoma/frontend_settings/pleroma-fe/${name}`
|
||||
const AKKOMA_SETTING_PROFILE_LIST = `/api/v1/akkoma/frontend_settings/pleroma-fe`
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
||||
|
@ -1451,6 +1453,40 @@ const deleteAnnouncement = ({ id, credentials }) => {
|
|||
})
|
||||
}
|
||||
|
||||
const getSettingsProfile = ({ profileName, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: AKKOMA_SETTING_PROFILE_URL(profileName),
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const saveSettingsProfile = ({ profileName, credentials, settings, version }) => {
|
||||
return promisedRequest({
|
||||
url: AKKOMA_SETTING_PROFILE_URL(profileName),
|
||||
method: 'PUT',
|
||||
credentials,
|
||||
payload: {
|
||||
settings,
|
||||
version
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deleteSettingsProfile = ({ profileName, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: AKKOMA_SETTING_PROFILE_URL(profileName),
|
||||
method: 'DELETE',
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const listSettingsProfiles = ({ credentials }) => {
|
||||
return promisedRequest({
|
||||
url: AKKOMA_SETTING_PROFILE_LIST,
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => {
|
||||
return Object.entries({
|
||||
...(credentials
|
||||
|
@ -1677,7 +1713,11 @@ const apiService = {
|
|||
deleteAnnouncement,
|
||||
adminFetchAnnouncements,
|
||||
translateStatus,
|
||||
getSupportedTranslationlanguages
|
||||
getSupportedTranslationlanguages,
|
||||
getSettingsProfile,
|
||||
saveSettingsProfile,
|
||||
listSettingsProfiles,
|
||||
deleteSettingsProfile
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
|
@ -4,6 +4,7 @@ import notificationsFetcher from '../notifications_fetcher/notifications_fetcher
|
|||
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
||||
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'
|
||||
|
||||
const backendInteractorService = credentials => ({
|
||||
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
|
||||
|
@ -18,6 +19,10 @@ const backendInteractorService = credentials => ({
|
|||
return notificationsFetcher.startFetching({ store, credentials })
|
||||
},
|
||||
|
||||
startFetchingConfig ({ store }) {
|
||||
return configFetcher.startFetching({ store, credentials })
|
||||
},
|
||||
|
||||
fetchNotifications (args) {
|
||||
return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
|
||||
},
|
||||
|
|
13
src/services/config_fetcher/config_fetcher.service.js
Normal file
13
src/services/config_fetcher/config_fetcher.service.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const startFetching = ({ credentials, store }) => {
|
||||
const boundFetchAndUpdate = () => store.dispatch('getSettingsProfile')
|
||||
boundFetchAndUpdate()
|
||||
return promiseInterval(boundFetchAndUpdate, 5 * 60000)
|
||||
}
|
||||
|
||||
const configFetcher = {
|
||||
startFetching
|
||||
}
|
||||
|
||||
export default configFetcher
|
Loading…
Add table
Add a link
Reference in a new issue