forked from AkkomaGang/akkoma-fe
more refactoring
This commit is contained in:
parent
2db991fc7f
commit
82fa5d08c4
11 changed files with 109 additions and 76 deletions
|
@ -60,10 +60,10 @@ export default {
|
||||||
},
|
},
|
||||||
logo () { return this.$store.state.config.logo },
|
logo () { return this.$store.state.config.logo },
|
||||||
style () { return { 'background-image': `url(${this.background})` } },
|
style () { return { 'background-image': `url(${this.background})` } },
|
||||||
sitename () { return this.$store.state.interface.name },
|
sitename () { return this.$store.state.instance.name },
|
||||||
chat () { return this.$store.state.chat.channel.state === 'joined' },
|
chat () { return this.$store.state.chat.channel.state === 'joined' },
|
||||||
suggestionsEnabled () { return this.$store.state.interface.suggestionsEnabled },
|
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
|
||||||
showInstanceSpecificPanel () { return this.$store.state.interface.showInstanceSpecificPanel }
|
showInstanceSpecificPanel () { return this.$store.state.instance.showInstanceSpecificPanel }
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
activatePanel (panelName) {
|
activatePanel (panelName) {
|
||||||
|
|
|
@ -3,11 +3,11 @@ const FeaturesPanel = {
|
||||||
chat: function () {
|
chat: function () {
|
||||||
return this.$store.state.config.chatAvailable && (!this.$store.state.chatDisabled)
|
return this.$store.state.config.chatAvailable && (!this.$store.state.chatDisabled)
|
||||||
},
|
},
|
||||||
gopher: function () { return this.$store.state.config.gopherAvailable },
|
gopher: function () { return this.$store.state.instance.gopherAvailable },
|
||||||
whoToFollow: function () { return this.$store.state.config.suggestionsEnabled },
|
whoToFollow: function () { return this.$store.state.instance.suggestionsEnabled },
|
||||||
mediaProxy: function () { return this.$store.state.config.mediaProxyAvailable },
|
mediaProxy: function () { return this.$store.state.instance.mediaProxyAvailable },
|
||||||
scopeOptions: function () { return this.$store.state.config.scopeOptionsEnabled },
|
scopeOptions: function () { return this.$store.state.instance.scopeOptionsEnabled },
|
||||||
textlimit: function () { return this.$store.state.config.textlimit }
|
textlimit: function () { return this.$store.state.instance.textlimit }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const LoginForm = {
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
loggingIn () { return this.$store.state.users.loggingIn },
|
loggingIn () { return this.$store.state.users.loggingIn },
|
||||||
registrationOpen () { return this.$store.state.interface.registrationOpen }
|
registrationOpen () { return this.$store.state.instance.registrationOpen }
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit () {
|
submit () {
|
||||||
|
|
|
@ -120,10 +120,10 @@ const PostStatusForm = {
|
||||||
return this.$store.state.users.users
|
return this.$store.state.users.users
|
||||||
},
|
},
|
||||||
emoji () {
|
emoji () {
|
||||||
return this.$store.state.config.emoji || []
|
return this.$store.state.instance.emoji || []
|
||||||
},
|
},
|
||||||
customEmoji () {
|
customEmoji () {
|
||||||
return this.$store.state.config.customEmoji || []
|
return this.$store.state.instance.customEmoji || []
|
||||||
},
|
},
|
||||||
statusLength () {
|
statusLength () {
|
||||||
return this.newStatus.status.length
|
return this.newStatus.status.length
|
||||||
|
@ -141,10 +141,10 @@ const PostStatusForm = {
|
||||||
return this.hasStatusLengthLimit && (this.statusLength > this.statusLengthLimit)
|
return this.hasStatusLengthLimit && (this.statusLength > this.statusLengthLimit)
|
||||||
},
|
},
|
||||||
scopeOptionsEnabled () {
|
scopeOptionsEnabled () {
|
||||||
return this.$store.state.config.scopeOptionsEnabled
|
return this.$store.state.instance.scopeOptionsEnabled
|
||||||
},
|
},
|
||||||
formattingOptionsEnabled () {
|
formattingOptionsEnabled () {
|
||||||
return this.$store.state.config.formattingOptionsEnabled
|
return this.$store.state.instance.formattingOptionsEnabled
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -5,16 +5,16 @@ const registration = {
|
||||||
registering: false
|
registering: false
|
||||||
}),
|
}),
|
||||||
created () {
|
created () {
|
||||||
if ((!this.$store.state.interface.registrationOpen && !this.token) || !!this.$store.state.users.currentUser) {
|
if ((!this.$store.state.instance.registrationOpen && !this.token) || !!this.$store.state.users.currentUser) {
|
||||||
this.$router.push('/main/all')
|
this.$router.push('/main/all')
|
||||||
}
|
}
|
||||||
// Seems like this doesn't work at first page open for some reason
|
// Seems like this doesn't work at first page open for some reason
|
||||||
if (this.$store.state.interface.registrationOpen && this.token) {
|
if (this.$store.state.instance.registrationOpen && this.token) {
|
||||||
this.$router.push('/registration')
|
this.$router.push('/registration')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
termsofservice () { return this.$store.state.config.tos },
|
termsofservice () { return this.$store.state.instance.tos },
|
||||||
token () { return this.$route.params.token }
|
token () { return this.$route.params.token }
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -6,25 +6,26 @@ import { filter, trim } from 'lodash'
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
data () {
|
data () {
|
||||||
const config = this.$store.state.config
|
const user = this.$store.state.config
|
||||||
|
const instance = this.$store.state.instance
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hideAttachmentsLocal: config.hideAttachments,
|
hideAttachmentsLocal: user.hideAttachments,
|
||||||
hideAttachmentsInConvLocal: config.hideAttachmentsInConv,
|
hideAttachmentsInConvLocal: user.hideAttachmentsInConv,
|
||||||
hideNsfwLocal: config.hideNsfw,
|
hideNsfwLocal: user.hideNsfw,
|
||||||
notificationVisibilityLocal: config.notificationVisibility,
|
notificationVisibilityLocal: user.notificationVisibility,
|
||||||
replyVisibilityLocal: config.replyVisibility,
|
replyVisibilityLocal: user.replyVisibility,
|
||||||
loopVideoLocal: config.loopVideo,
|
loopVideoLocal: user.loopVideo,
|
||||||
loopVideoSilentOnlyLocal: config.loopVideoSilentOnly,
|
loopVideoSilentOnlyLocal: user.loopVideoSilentOnly,
|
||||||
muteWordsString: config.muteWords.join('\n'),
|
muteWordsString: user.muteWords.join('\n'),
|
||||||
autoLoadLocal: config.autoLoad,
|
autoLoadLocal: user.autoLoad,
|
||||||
streamingLocal: config.streaming,
|
streamingLocal: user.streaming,
|
||||||
pauseOnUnfocusedLocal: config.pauseOnUnfocused,
|
pauseOnUnfocusedLocal: user.pauseOnUnfocused,
|
||||||
hoverPreviewLocal: config.hoverPreview,
|
hoverPreviewLocal: user.hoverPreview,
|
||||||
collapseMessageWithSubjectLocal: typeof config.collapseMessageWithSubject === 'undefined'
|
collapseMessageWithSubjectLocal: typeof user.collapseMessageWithSubject === 'undefined'
|
||||||
? config.defaultCollapseMessageWithSubject
|
? instance.collapseMessageWithSubject
|
||||||
: config.collapseMessageWithSubject,
|
: user.collapseMessageWithSubject,
|
||||||
stopGifs: config.stopGifs,
|
stopGifs: user.stopGifs,
|
||||||
loopSilentAvailable:
|
loopSilentAvailable:
|
||||||
// Firefox
|
// Firefox
|
||||||
Object.getOwnPropertyDescriptor(HTMLVideoElement.prototype, 'mozHasAudio') ||
|
Object.getOwnPropertyDescriptor(HTMLVideoElement.prototype, 'mozHasAudio') ||
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<template v-if="currentSaveStateNotice">
|
<template v-if="currentSaveStateNotice">
|
||||||
<div @click.prevent class="alert error" v-if="!currentSaveStateNotice.error">
|
<div @click.prevent class="alert error" v-if="currentSaveStateNotice.error">
|
||||||
Errr
|
Errr
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@ const UserSettings = {
|
||||||
return this.$store.state.users.currentUser
|
return this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
pleromaBackend () {
|
pleromaBackend () {
|
||||||
return this.$store.state.config.pleromaBackend
|
return this.$store.state.instance.pleromaBackend
|
||||||
},
|
},
|
||||||
scopeOptionsEnabled () {
|
scopeOptionsEnabled () {
|
||||||
return this.$store.state.config.scopeOptionsEnabled
|
return this.$store.state.instance.scopeOptionsEnabled
|
||||||
},
|
},
|
||||||
vis () {
|
vis () {
|
||||||
return {
|
return {
|
||||||
|
|
44
src/main.js
44
src/main.js
|
@ -15,6 +15,7 @@ import UserSettings from './components/user_settings/user_settings.vue'
|
||||||
import FollowRequests from './components/follow_requests/follow_requests.vue'
|
import FollowRequests from './components/follow_requests/follow_requests.vue'
|
||||||
|
|
||||||
import interfaceModule from './modules/interface.js'
|
import interfaceModule from './modules/interface.js'
|
||||||
|
import instanceModule from './modules/instance.js'
|
||||||
import statusesModule from './modules/statuses.js'
|
import statusesModule from './modules/statuses.js'
|
||||||
import usersModule from './modules/users.js'
|
import usersModule from './modules/users.js'
|
||||||
import apiModule from './modules/api.js'
|
import apiModule from './modules/api.js'
|
||||||
|
@ -68,9 +69,10 @@ const persistedStateOptions = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = console.log('interfaceModule') || new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
interface: interfaceModule,
|
interface: interfaceModule,
|
||||||
|
instance: instanceModule,
|
||||||
statuses: statusesModule,
|
statuses: statusesModule,
|
||||||
users: usersModule,
|
users: usersModule,
|
||||||
api: apiModule,
|
api: apiModule,
|
||||||
|
@ -122,15 +124,15 @@ window.fetch('/api/statusnet/config.json')
|
||||||
var formattingOptionsEnabled = (config.formattingOptionsEnabled)
|
var formattingOptionsEnabled = (config.formattingOptionsEnabled)
|
||||||
var defaultCollapseMessageWithSubject = (config.collapseMessageWithSubject)
|
var defaultCollapseMessageWithSubject = (config.collapseMessageWithSubject)
|
||||||
|
|
||||||
store.dispatch('setOption', { name: 'theme', value: theme })
|
store.dispatch('setInstanceOption', { name: 'theme', value: theme })
|
||||||
store.dispatch('setOption', { name: 'background', value: background })
|
store.dispatch('setInstanceOption', { name: 'background', value: background })
|
||||||
store.dispatch('setOption', { name: 'logo', value: logo })
|
store.dispatch('setInstanceOption', { name: 'logo', value: logo })
|
||||||
store.dispatch('setOption', { name: 'logoMask', value: logoMask })
|
store.dispatch('setInstanceOption', { name: 'logoMask', value: logoMask })
|
||||||
store.dispatch('setOption', { name: 'logoMargin', value: logoMargin })
|
store.dispatch('setInstanceOption', { name: 'logoMargin', value: logoMargin })
|
||||||
store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
store.dispatch('setInstanceOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
||||||
store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
|
store.dispatch('setInstanceOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
|
||||||
store.dispatch('setOption', { name: 'formattingOptionsEnabled', value: formattingOptionsEnabled })
|
store.dispatch('setInstanceOption', { name: 'formattingOptionsEnabled', value: formattingOptionsEnabled })
|
||||||
store.dispatch('setOption', { name: 'defaultCollapseMessageWithSubject', value: defaultCollapseMessageWithSubject })
|
store.dispatch('setInstanceOption', { name: 'collapseMessageWithSubject', value: defaultCollapseMessageWithSubject })
|
||||||
if (chatDisabled) {
|
if (chatDisabled) {
|
||||||
store.dispatch('disableChat')
|
store.dispatch('disableChat')
|
||||||
}
|
}
|
||||||
|
@ -180,7 +182,7 @@ window.fetch('/api/statusnet/config.json')
|
||||||
window.fetch('/static/terms-of-service.html')
|
window.fetch('/static/terms-of-service.html')
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
store.dispatch('setOption', { name: 'tos', value: html })
|
store.dispatch('setInstanceOption', { name: 'tos', value: html })
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fetch('/api/pleroma/emoji.json')
|
window.fetch('/api/pleroma/emoji.json')
|
||||||
|
@ -191,11 +193,11 @@ window.fetch('/api/pleroma/emoji.json')
|
||||||
const emoji = Object.keys(values).map((key) => {
|
const emoji = Object.keys(values).map((key) => {
|
||||||
return { shortcode: key, image_url: values[key] }
|
return { shortcode: key, image_url: values[key] }
|
||||||
})
|
})
|
||||||
store.dispatch('setOption', { name: 'customEmoji', value: emoji })
|
store.dispatch('setInstanceOption', { name: 'customEmoji', value: emoji })
|
||||||
store.dispatch('setOption', { name: 'pleromaBackend', value: true })
|
store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: true })
|
||||||
},
|
},
|
||||||
(failure) => {
|
(failure) => {
|
||||||
store.dispatch('setOption', { name: 'pleromaBackend', value: false })
|
store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: false })
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
(error) => console.log(error)
|
(error) => console.log(error)
|
||||||
|
@ -207,24 +209,24 @@ window.fetch('/static/emoji.json')
|
||||||
const emoji = Object.keys(values).map((key) => {
|
const emoji = Object.keys(values).map((key) => {
|
||||||
return { shortcode: key, image_url: false, 'utf': values[key] }
|
return { shortcode: key, image_url: false, 'utf': values[key] }
|
||||||
})
|
})
|
||||||
store.dispatch('setOption', { name: 'emoji', value: emoji })
|
store.dispatch('setInstanceOption', { name: 'emoji', value: emoji })
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fetch('/instance/panel.html')
|
window.fetch('/instance/panel.html')
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
store.dispatch('setOption', { name: 'instanceSpecificPanelContent', value: html })
|
store.dispatch('setInstanceOption', { name: 'instanceSpecificPanelContent', value: html })
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fetch('/nodeinfo/2.0.json')
|
window.fetch('/nodeinfo/2.0.json')
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const metadata = data.metadata
|
const metadata = data.metadata
|
||||||
store.dispatch('setOption', { name: 'mediaProxyAvailable', value: data.metadata.mediaProxy })
|
store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: data.metadata.mediaProxy })
|
||||||
store.dispatch('setOption', { name: 'chatAvailable', value: data.metadata.chat })
|
store.dispatch('setInstanceOption', { name: 'chatAvailable', value: data.metadata.chat })
|
||||||
store.dispatch('setOption', { name: 'gopherAvailable', value: data.metadata.gopher })
|
store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: data.metadata.gopher })
|
||||||
|
|
||||||
const suggestions = metadata.suggestions
|
const suggestions = metadata.suggestions
|
||||||
store.dispatch('setOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
|
store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
|
||||||
store.dispatch('setOption', { name: 'suggestionsWeb', value: suggestions.web })
|
store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web })
|
||||||
})
|
})
|
||||||
|
|
47
src/modules/instance.js
Normal file
47
src/modules/instance.js
Normal 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
|
|
@ -1,10 +1,6 @@
|
||||||
import { set, delete as del } from 'vue'
|
import { set, delete as del } from 'vue'
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
name: 'Pleroma FE',
|
|
||||||
registrationOpen: true,
|
|
||||||
textlimit: 5000,
|
|
||||||
server: 'http://localhost:4040/',
|
|
||||||
settings: {
|
settings: {
|
||||||
currentSaveStateNotice: null,
|
currentSaveStateNotice: null,
|
||||||
noticeClearTimeout: null
|
noticeClearTimeout: null
|
||||||
|
@ -14,11 +10,6 @@ const defaultState = {
|
||||||
const interfaceMod = {
|
const interfaceMod = {
|
||||||
state: defaultState,
|
state: defaultState,
|
||||||
mutations: {
|
mutations: {
|
||||||
setInstanceOption (state, { name, value }) {
|
|
||||||
console.log(state)
|
|
||||||
console.log(name)
|
|
||||||
set(state, name, value)
|
|
||||||
},
|
|
||||||
settingsSaved (state, { success, error }) {
|
settingsSaved (state, { success, error }) {
|
||||||
if (success) {
|
if (success) {
|
||||||
if (state.noticeClearTimeout) {
|
if (state.noticeClearTimeout) {
|
||||||
|
@ -33,19 +24,11 @@ const interfaceMod = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setPageTitle ({state}, option = '') {
|
setPageTitle ({ rootState }, option = '') {
|
||||||
document.title = `${option} ${state.name}`
|
document.title = `${option} ${rootState.instance.name}`
|
||||||
},
|
},
|
||||||
settingsSaved ({ commit, dispatch }, { success, error }) {
|
settingsSaved ({ commit, dispatch }, { success, error }) {
|
||||||
commit('settingsSaved', { success, error })
|
commit('settingsSaved', { success, error })
|
||||||
},
|
|
||||||
setInstanceOption ({ commit, dispatch }, { name, value }) {
|
|
||||||
commit('setInstanceOption', {name, value})
|
|
||||||
switch (name) {
|
|
||||||
case 'name':
|
|
||||||
dispatch('setPageTitle')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue