Merge branch 'fix/dont-connect-ws-when-chat-disabled' into 'develop'

fix #288 - Don't connect WS when chat is disabled

Closes #288

See merge request pleroma/pleroma-fe!492
This commit is contained in:
lambda 2019-01-29 15:57:36 +00:00
commit bd6c446b33
3 changed files with 13 additions and 4 deletions

View File

@ -89,6 +89,8 @@ const afterStoreSetup = ({ store, i18n }) => {
if ((config.chatDisabled)) { if ((config.chatDisabled)) {
store.dispatch('disableChat') store.dispatch('disableChat')
} else {
store.dispatch('initializeSocket')
} }
const router = new VueRouter({ const router = new VueRouter({

View File

@ -20,6 +20,9 @@ const api = {
removeFetcher (state, {timeline}) { removeFetcher (state, {timeline}) {
delete state.fetchers[timeline] delete state.fetchers[timeline]
}, },
setWsToken (state, token) {
state.wsToken = token
},
setSocket (state, socket) { setSocket (state, socket) {
state.socket = socket state.socket = socket
}, },
@ -51,10 +54,14 @@ const api = {
window.clearInterval(fetcher) window.clearInterval(fetcher)
store.commit('removeFetcher', {timeline}) store.commit('removeFetcher', {timeline})
}, },
initializeSocket (store, token) { setWsToken (store, token) {
store.commit('setWsToken', token)
},
initializeSocket (store) {
// Set up websocket connection // Set up websocket connection
if (!store.state.chatDisabled) { if (!store.state.chatDisabled) {
let socket = new Socket('/socket', {params: {token: token}}) const token = store.state.wsToken
const socket = new Socket('/socket', {params: {token}})
socket.connect() socket.connect()
store.dispatch('initializeChat', socket) store.dispatch('initializeChat', socket)
} }

View File

@ -224,10 +224,10 @@ const users = {
commit('setBackendInteractor', backendInteractorService(accessToken)) commit('setBackendInteractor', backendInteractorService(accessToken))
if (user.token) { if (user.token) {
store.dispatch('initializeSocket', user.token) store.dispatch('setWsToken', user.token)
} }
// Start getting fresh tweets. // Start getting fresh posts.
store.dispatch('startFetching', 'friends') store.dispatch('startFetching', 'friends')
// Get user mutes and follower info // Get user mutes and follower info