forked from AkkomaGang/akkoma-fe
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:
commit
bd6c446b33
3 changed files with 13 additions and 4 deletions
|
@ -89,6 +89,8 @@ const afterStoreSetup = ({ store, i18n }) => {
|
|||
|
||||
if ((config.chatDisabled)) {
|
||||
store.dispatch('disableChat')
|
||||
} else {
|
||||
store.dispatch('initializeSocket')
|
||||
}
|
||||
|
||||
const router = new VueRouter({
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue