From 82fa5d08c4f441fa9df20edab214b99ecb7776b3 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 9 Sep 2018 21:21:23 +0300 Subject: more refactoring --- src/modules/instance.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/modules/instance.js (limited to 'src/modules/instance.js') diff --git a/src/modules/instance.js b/src/modules/instance.js new file mode 100644 index 00000000..228cee4c --- /dev/null +++ b/src/modules/instance.js @@ -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 -- cgit v1.2.3-70-g09d2 From 580aae1b545331b284724e54cc31c99e52862f57 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 9 Sep 2018 21:51:40 +0300 Subject: Added more stuff that's actually being added to instanceConfig, simplified the whitelist. --- src/lib/persisted_state.js | 1 + src/main.js | 20 +++----------------- src/modules/instance.js | 11 +++++++++++ 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/modules/instance.js') diff --git a/src/lib/persisted_state.js b/src/lib/persisted_state.js index 007515cd..c9eac91f 100644 --- a/src/lib/persisted_state.js +++ b/src/lib/persisted_state.js @@ -16,6 +16,7 @@ const saveImmedeatelyActions = [ 'markNotificationsAsSeen', 'clearCurrentUser', 'setCurrentUser', + 'setHighlight', 'setOption' ] diff --git a/src/main.js b/src/main.js index 23bd2cd3..4e7b55bb 100644 --- a/src/main.js +++ b/src/main.js @@ -47,23 +47,7 @@ Vue.use(VueChatScroll) const persistedStateOptions = { paths: [ - 'config.collapseMessageWithSubject', - 'config.hideAttachments', - 'config.hideAttachmentsInConv', - 'config.hideNsfw', - 'config.replyVisibility', - 'config.notificationVisibility', - 'config.autoLoad', - 'config.hoverPreview', - 'config.streaming', - 'config.muteWords', - 'config.customTheme', - 'config.highlight', - 'config.loopVideo', - 'config.loopVideoSilentOnly', - 'config.pauseOnUnfocused', - 'config.stopGifs', - 'config.interfaceLanguage', + 'config', 'users.lastLoginName', 'statuses.notifications.maxSavedId' ] @@ -129,6 +113,8 @@ window.fetch('/api/statusnet/config.json') store.dispatch('setInstanceOption', { name: 'logo', value: logo }) store.dispatch('setInstanceOption', { name: 'logoMask', value: logoMask }) store.dispatch('setInstanceOption', { name: 'logoMargin', value: logoMargin }) + store.dispatch('setInstanceOption', { name: 'redirectRootNoLogin', value: redirectRootNoLogin }) + store.dispatch('setInstanceOption', { name: 'redirectRootLogin', value: redirectRootLogin }) store.dispatch('setInstanceOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel }) store.dispatch('setInstanceOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled }) store.dispatch('setInstanceOption', { name: 'formattingOptionsEnabled', value: formattingOptionsEnabled }) diff --git a/src/modules/instance.js b/src/modules/instance.js index 228cee4c..a4fc9651 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -1,6 +1,7 @@ import { set } from 'vue' const defaultState = { + // Stuff from static/config.json and apiConfig name: 'Pleroma FE', registrationOpen: true, textlimit: 5000, @@ -17,9 +18,19 @@ const defaultState = { formattingOptionsEnabled: false, collapseMessageWithSubject: false, disableChat: false, + // Nasty stuff pleromaBackend: true, + emoji: [], customEmoji: [], + + // Feature-set, apparently, not everything here is reported... + mediaProxyAvailable: false, + chatAvailable: false, + gopherAvailable: false, + suggestionsEnabled: false, + suggestionsWeb: '', + // Html stuff instanceSpecificPanelContent: '', tos: '' -- cgit v1.2.3-70-g09d2 From 9467462ef0c3ed450332a1e2335dce52b7d578f1 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 17 Sep 2018 18:54:08 +0300 Subject: made FE work even without either api or static config --- src/main.js | 4 +++- src/modules/instance.js | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/modules/instance.js') diff --git a/src/main.js b/src/main.js index 5314437b..b8dfcf68 100644 --- a/src/main.js +++ b/src/main.js @@ -132,7 +132,9 @@ window.fetch('/api/statusnet/config.json') { name: 'root', path: '/', redirect: to => { - return (store.state.users.currentUser ? redirectRootLogin : redirectRootNoLogin) || '/main/all' + return (store.state.users.currentUser + ? store.state.instance.redirectRootLogin + : store.state.instance.redirectRootNoLogin) || '/main/all' }}, { path: '/main/all', component: PublicAndExternalTimeline }, { path: '/main/public', component: PublicTimeline }, diff --git a/src/modules/instance.js b/src/modules/instance.js index a4fc9651..cb724821 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -1,4 +1,5 @@ import { set } from 'vue' +import StyleSetter from '../services/style_setter/style_setter.js' const defaultState = { // Stuff from static/config.json and apiConfig @@ -7,7 +8,7 @@ const defaultState = { textlimit: 5000, server: 'http://localhost:4040/', theme: 'pleroma-dark', - background: 'img.png', + background: '/static/aurora_borealis.jpg', logo: '/static/logo.png', logoMask: true, logoMargin: '.2em', @@ -40,7 +41,9 @@ const instance = { state: defaultState, mutations: { setInstanceOption (state, { name, value }) { - set(state, name, value) + if (typeof value !== 'undefined') { + set(state, name, value) + } } }, actions: { @@ -50,6 +53,8 @@ const instance = { case 'name': dispatch('setPageTitle') break + case 'theme': + StyleSetter.setPreset(value, commit) } } } -- cgit v1.2.3-70-g09d2