more refactoring

This commit is contained in:
Henry Jameson 2018-09-09 21:21:23 +03:00
parent 2db991fc7f
commit 82fa5d08c4
11 changed files with 109 additions and 76 deletions

47
src/modules/instance.js Normal file
View file

@ -0,0 +1,47 @@
import { set } from 'vue'
const defaultState = {
name: 'Pleroma FE',
registrationOpen: true,
textlimit: 5000,
server: 'http://localhost:4040/',
theme: 'pleroma-dark',
background: 'img.png',
logo: '/static/logo.png',
logoMask: true,
logoMargin: '.2em',
redirectRootNoLogin: '/main/all',
redirectRootLogin: '/main/friends',
showInstanceSpecificPanel: false,
scopeOptionsEnabled: true,
formattingOptionsEnabled: false,
collapseMessageWithSubject: false,
disableChat: false,
// Nasty stuff
pleromaBackend: true,
customEmoji: [],
// Html stuff
instanceSpecificPanelContent: '',
tos: ''
}
const instance = {
state: defaultState,
mutations: {
setInstanceOption (state, { name, value }) {
set(state, name, value)
}
},
actions: {
setInstanceOption ({ commit, dispatch }, { name, value }) {
commit('setInstanceOption', {name, value})
switch (name) {
case 'name':
dispatch('setPageTitle')
break
}
}
}
}
export default instance

View file

@ -1,10 +1,6 @@
import { set, delete as del } from 'vue'
const defaultState = {
name: 'Pleroma FE',
registrationOpen: true,
textlimit: 5000,
server: 'http://localhost:4040/',
settings: {
currentSaveStateNotice: null,
noticeClearTimeout: null
@ -14,11 +10,6 @@ const defaultState = {
const interfaceMod = {
state: defaultState,
mutations: {
setInstanceOption (state, { name, value }) {
console.log(state)
console.log(name)
set(state, name, value)
},
settingsSaved (state, { success, error }) {
if (success) {
if (state.noticeClearTimeout) {
@ -33,19 +24,11 @@ const interfaceMod = {
}
},
actions: {
setPageTitle ({state}, option = '') {
document.title = `${option} ${state.name}`
setPageTitle ({ rootState }, option = '') {
document.title = `${option} ${rootState.instance.name}`
},
settingsSaved ({ commit, dispatch }, { success, error }) {
commit('settingsSaved', { success, error })
},
setInstanceOption ({ commit, dispatch }, { name, value }) {
commit('setInstanceOption', {name, value})
switch (name) {
case 'name':
dispatch('setPageTitle')
break
}
}
}
}