2018-08-15 19:51:21 +10:00
|
|
|
/* eslint-env browser */
|
2019-03-11 10:58:12 +11:00
|
|
|
import { filter, trim } from 'lodash'
|
|
|
|
|
2019-02-01 02:00:31 +11:00
|
|
|
import TabSwitcher from '../tab_switcher/tab_switcher.js'
|
2017-02-17 08:25:29 +11:00
|
|
|
import StyleSwitcher from '../style_switcher/style_switcher.vue'
|
2018-08-25 20:12:33 +10:00
|
|
|
import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'
|
2019-03-11 12:06:51 +11:00
|
|
|
import { extractCommit } from '../../services/version/version.service'
|
2019-09-30 06:47:26 +10:00
|
|
|
import { instanceDefaultProperties, defaultState as configDefaultState } from '../../modules/config.js'
|
2019-03-11 12:06:51 +11:00
|
|
|
|
|
|
|
const pleromaFeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma-fe/commit/'
|
|
|
|
const pleromaBeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma/commit/'
|
2017-02-17 08:25:29 +11:00
|
|
|
|
2019-09-30 07:04:43 +10:00
|
|
|
const multiChoiceProperties = [
|
|
|
|
'postContentType',
|
|
|
|
'subjectLineBehavior'
|
|
|
|
]
|
|
|
|
|
2017-02-17 08:25:29 +11:00
|
|
|
const settings = {
|
2017-02-23 10:04:47 +11:00
|
|
|
data () {
|
2018-09-10 04:21:23 +10:00
|
|
|
const instance = this.$store.state.instance
|
2018-09-04 05:40:45 +10:00
|
|
|
|
2017-02-23 10:04:47 +11:00
|
|
|
return {
|
2019-01-27 02:45:03 +11:00
|
|
|
loopSilentAvailable:
|
|
|
|
// Firefox
|
|
|
|
Object.getOwnPropertyDescriptor(HTMLVideoElement.prototype, 'mozHasAudio') ||
|
|
|
|
// Chrome-likes
|
|
|
|
Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'webkitAudioDecodedByteCount') ||
|
|
|
|
// Future spec, still not supported in Nightly 63 as of 08/2018
|
|
|
|
Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'audioTracks'),
|
2019-03-11 10:58:12 +11:00
|
|
|
|
|
|
|
backendVersion: instance.backendVersion,
|
|
|
|
frontendVersion: instance.frontendVersion
|
2017-02-23 10:04:47 +11:00
|
|
|
}
|
|
|
|
},
|
2017-02-17 08:25:29 +11:00
|
|
|
components: {
|
2018-08-28 21:28:05 +10:00
|
|
|
TabSwitcher,
|
2018-08-25 20:12:33 +10:00
|
|
|
StyleSwitcher,
|
|
|
|
InterfaceLanguageSwitcher
|
2017-02-23 10:04:47 +11:00
|
|
|
},
|
2017-04-16 21:44:11 +10:00
|
|
|
computed: {
|
|
|
|
user () {
|
|
|
|
return this.$store.state.users.currentUser
|
2018-09-08 01:17:17 +10:00
|
|
|
},
|
|
|
|
currentSaveStateNotice () {
|
2018-09-10 02:36:13 +10:00
|
|
|
return this.$store.state.interface.settings.currentSaveStateNotice
|
2019-02-18 07:24:24 +11:00
|
|
|
},
|
2019-03-05 16:29:56 +11:00
|
|
|
postFormats () {
|
|
|
|
return this.$store.state.instance.postFormats || []
|
|
|
|
},
|
2019-03-11 12:06:51 +11:00
|
|
|
instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel },
|
|
|
|
frontendVersionLink () {
|
2019-03-11 12:13:01 +11:00
|
|
|
return pleromaFeCommitUrl + this.frontendVersion
|
2019-03-11 10:58:12 +11:00
|
|
|
},
|
2019-03-11 12:06:51 +11:00
|
|
|
backendVersionLink () {
|
2019-03-11 12:13:01 +11:00
|
|
|
return pleromaBeCommitUrl + extractCommit(this.backendVersion)
|
2019-09-30 06:47:26 +10:00
|
|
|
},
|
|
|
|
// Getting localized values for instance-default properties
|
|
|
|
...instanceDefaultProperties
|
2019-09-30 07:04:43 +10:00
|
|
|
.filter(key => multiChoiceProperties.includes(key))
|
|
|
|
.map(key => [
|
|
|
|
key + 'DefaultValue',
|
|
|
|
function () {
|
|
|
|
return this.$store.getters.instanceDefaultConfig[key]
|
|
|
|
}
|
|
|
|
])
|
|
|
|
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
|
|
|
...instanceDefaultProperties
|
|
|
|
.filter(key => !multiChoiceProperties.includes(key))
|
2019-09-30 06:47:26 +10:00
|
|
|
.map(key => [
|
|
|
|
key + 'LocalizedValue',
|
|
|
|
function () {
|
|
|
|
return this.$t('settings.values.' + this.$store.getters.instanceDefaultConfig[key])
|
|
|
|
}
|
|
|
|
])
|
|
|
|
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
|
|
|
// Generating computed values for vuex properties
|
|
|
|
...Object.keys(configDefaultState)
|
|
|
|
.map(key => [key, {
|
|
|
|
get () { return this.$store.getters.mergedConfig[key] },
|
|
|
|
set (value) {
|
|
|
|
this.$store.dispatch('setOption', { name: key, value })
|
|
|
|
}
|
|
|
|
}])
|
|
|
|
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
|
|
|
// Special cases (need to transform values)
|
|
|
|
muteWordsString: {
|
|
|
|
get () { return this.$store.getters.mergedConfig.muteWords.join('\n') },
|
|
|
|
set (value) {
|
|
|
|
this.$store.dispatch('setOption', {
|
|
|
|
name: 'muteWords',
|
|
|
|
value: filter(value.split('\n'), (word) => trim(word).length > 0)
|
|
|
|
})
|
|
|
|
}
|
2019-03-11 10:58:12 +11:00
|
|
|
}
|
2017-04-16 21:44:11 +10:00
|
|
|
},
|
2019-09-30 06:47:26 +10:00
|
|
|
// Updating nested properties
|
2017-02-23 10:04:47 +11:00
|
|
|
watch: {
|
2019-09-30 06:47:26 +10:00
|
|
|
notificationVisibility: {
|
|
|
|
handler (value) {
|
|
|
|
this.$store.dispatch('setOption', {
|
|
|
|
name: 'notificationVisibility',
|
|
|
|
value: this.$store.state.config.notificationVisibility
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deep: true
|
2017-02-23 10:38:05 +11:00
|
|
|
}
|
2017-02-17 08:25:29 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default settings
|