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)) {
store.dispatch('disableChat')
} else {
store.dispatch('initializeSocket')
}
const router = new VueRouter({

View file

@ -20,6 +20,9 @@ const api = {
removeFetcher (state, {timeline}) {
delete state.fetchers[timeline]
},
setWsToken (state, token) {
state.wsToken = token
},
setSocket (state, socket) {
state.socket = socket
},
@ -51,10 +54,14 @@ const api = {
window.clearInterval(fetcher)
store.commit('removeFetcher', {timeline})
},
initializeSocket (store, token) {
setWsToken (store, token) {
store.commit('setWsToken', token)
},
initializeSocket (store) {
// Set up websocket connection
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()
store.dispatch('initializeChat', socket)
}

View file

@ -224,10 +224,10 @@ const users = {
commit('setBackendInteractor', backendInteractorService(accessToken))
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')
// Get user mutes and follower info