setting-sync #175

Merged
floatingghost merged 6 commits from setting-sync into develop 2022-10-06 15:59:17 +00:00
6 changed files with 29 additions and 7 deletions
Showing only changes of commit d7c9cd7585 - Show all commits

View file

@ -399,6 +399,7 @@ const afterStoreSetup = async ({ store, i18n }) => {
getTOS({ store }) getTOS({ store })
getStickers({ store }) getStickers({ store })
store.dispatch('getSupportedTranslationlanguages') store.dispatch('getSupportedTranslationlanguages')
store.dispatch('getSettingsProfile')
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),

View file

@ -19,7 +19,7 @@ const SharedComputedObject = () => ({
.map(key => [key, { .map(key => [key, {
get () { return this.$store.getters.mergedConfig[key] }, get () { return this.$store.getters.mergedConfig[key] },
set (value) { set (value) {
this.$store.dispatch('setOption', { name: key, value }) this.$store.dispatch('setOption', { name: key, value, manual: true })
} }
}]) }])
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}), .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
@ -27,7 +27,7 @@ const SharedComputedObject = () => ({
.map(key => ['serverSide_' + key, { .map(key => ['serverSide_' + key, {
get () { return this.$store.state.serverSideConfig[key] }, get () { return this.$store.state.serverSideConfig[key] },
set (value) { set (value) {
this.$store.dispatch('setServerSideOption', { name: key, value }) this.$store.dispatch('setServerSideOption', { name: key, value, manual: true })
} }
}]) }])
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}), .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),

View file

@ -89,7 +89,7 @@ const GeneralTab = {
} }
}, },
translationLanguages () { translationLanguages () {
return (this.$store.getters.mergedConfig.supportedTranslationLanguages.target || []).map(lang => ({ key: lang.code, value: lang.code, label: lang.name })) return (this.$store.state.instance.supportedTranslationLanguages.target || []).map(lang => ({ key: lang.code, value: lang.code, label: lang.name }))
}, },
translationLanguage: { translationLanguage: {
get: function () { return this.$store.getters.mergedConfig.translationLanguage }, get: function () { return this.$store.getters.mergedConfig.translationLanguage },

View file

@ -262,10 +262,15 @@ const api = {
getSupportedTranslationlanguages (store) { getSupportedTranslationlanguages (store) {
store.state.backendInteractor.getSupportedTranslationlanguages({ store }) store.state.backendInteractor.getSupportedTranslationlanguages({ store })
.then((data) => { .then((data) => {
store.dispatch('setOption', { name: 'supportedTranslationLanguages', value: data }) store.dispatch('setInstanceOption', { name: 'supportedTranslationLanguages', value: data })
})
},
getSettingsProfile (store) {
store.state.backendInteractor.getSettingsProfile({ store })
.then((data) => {
console.log('LOADED', data)
}) })
}, },
// Pleroma websocket // Pleroma websocket
setWsToken (store, token) { setWsToken (store, token) {
store.commit('setWsToken', token) store.commit('setWsToken', token)

View file

@ -149,6 +149,7 @@ const config = {
mutations: { mutations: {
setOption (state, { name, value }) { setOption (state, { name, value }) {
state[name] = value state[name] = value
console.log('SETOPTION', JSON.stringify(state))
}, },
setHighlight (state, { user, color, type }) { setHighlight (state, { user, color, type }) {
const data = this.state.config.highlight[user] const data = this.state.config.highlight[user]
@ -160,6 +161,9 @@ const config = {
} }
}, },
actions: { actions: {
syncSettings: ({ dispatch }) => {
dispatch('syncSettingsToServer')
},
loadSettings ({ dispatch }, data) { loadSettings ({ dispatch }, data) {
const knownKeys = new Set(Object.keys(defaultState)) const knownKeys = new Set(Object.keys(defaultState))
const presentKeys = new Set(Object.keys(data)) const presentKeys = new Set(Object.keys(data))
@ -177,8 +181,11 @@ const config = {
setHighlight ({ commit, dispatch }, { user, color, type }) { setHighlight ({ commit, dispatch }, { user, color, type }) {
commit('setHighlight', { user, color, type }) commit('setHighlight', { user, color, type })
}, },
setOption ({ commit, dispatch }, { name, value }) { setOption ({ commit, dispatch }, { name, value, manual }) {
commit('setOption', { name, value }) commit('setOption', { name, value })
if (manual === true) {
dispatch('syncSettingsToServer')
}
switch (name) { switch (name) {
case 'theme': case 'theme':
setPreset(value) setPreset(value)

View file

@ -102,6 +102,7 @@ const PLEROMA_ANNOUNCEMENTS_URL = '/api/v1/pleroma/admin/announcements'
const PLEROMA_POST_ANNOUNCEMENT_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_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
const PLEROMA_DELETE_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 oldfetch = window.fetch const oldfetch = window.fetch
@ -1451,6 +1452,13 @@ const deleteAnnouncement = ({ id, credentials }) => {
}) })
} }
const getSettingsProfile = ({ profileName, credentials }) => {
return promisedRequest({
url: AKKOMA_SETTING_PROFILE_URL(profileName),
credentials
})
}
export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => { export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => {
return Object.entries({ return Object.entries({
...(credentials ...(credentials
@ -1677,7 +1685,8 @@ const apiService = {
deleteAnnouncement, deleteAnnouncement,
adminFetchAnnouncements, adminFetchAnnouncements,
translateStatus, translateStatus,
getSupportedTranslationlanguages getSupportedTranslationlanguages,
getSettingsProfile
} }
export default apiService export default apiService