diff options
| author | eal <eal@waifu.club> | 2017-12-07 18:20:44 +0200 |
|---|---|---|
| committer | eal <eal@waifu.club> | 2017-12-07 18:20:44 +0200 |
| commit | 612fb183671783c3ac3eeea21428c024a47713b1 (patch) | |
| tree | 13fb3a370772afcdacf85cab96cd9bd46d8bfdc3 | |
| parent | 6c4e3a509a23a4f683aee02fcd0b186813ae3de0 (diff) | |
Add option for disabling chat.
| -rw-r--r-- | src/main.js | 3 | ||||
| -rw-r--r-- | src/modules/api.js | 17 | ||||
| -rw-r--r-- | static/config.json | 3 |
3 files changed, 18 insertions, 5 deletions
diff --git a/src/main.js b/src/main.js index 72b75a52..a8ee5fda 100644 --- a/src/main.js +++ b/src/main.js @@ -82,6 +82,9 @@ window.fetch('/static/config.json') store.dispatch('setOption', { name: 'background', value: background }) store.dispatch('setOption', { name: 'logo', value: logo }) store.dispatch('setOption', { name: 'registrationOpen', value: registrationOpen }) + if (data['chatDisabled']) { + store.dispatch('disableChat') + } const routes = [ { name: 'root', path: '/', redirect: data['defaultPath'] || '/main/all' }, diff --git a/src/modules/api.js b/src/modules/api.js index ccd6cfb7..c91fb97b 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -6,7 +6,8 @@ const api = { state: { backendInteractor: backendInteractorService(), fetchers: {}, - socket: null + socket: null, + chatDisabled: false }, mutations: { setBackendInteractor (state, backendInteractor) { @@ -20,6 +21,9 @@ const api = { }, setSocket (state, socket) { state.socket = socket + }, + setChatDisabled (state, value) { + state.chatDisabled = value } }, actions: { @@ -45,9 +49,14 @@ const api = { }, initializeSocket (store, token) { // Set up websocket connection - let socket = new Socket('/socket', {params: {token: token}}) - socket.connect() - store.dispatch('initializeChat', socket) + if (!store.state.chatDisabled) { + let socket = new Socket('/socket', {params: {token: token}}) + socket.connect() + store.dispatch('initializeChat', socket) + } + }, + disableChat (store) { + store.commit('setChatDisabled', true) } } } diff --git a/static/config.json b/static/config.json index b186246b..880efca8 100644 --- a/static/config.json +++ b/static/config.json @@ -4,5 +4,6 @@ "background": "/static/bg.jpg", "logo": "/static/logo.png", "registrationOpen": false, - "defaultPath": "/main/all" + "defaultPath": "/main/all", + "chatDisabled": false } |
