Merge branch 'develop' into 'develop'
Only connect to chat upon authenticating Closes #403 See merge request pleroma/pleroma-fe!666
This commit is contained in:
commit
f52a33f711
@ -89,10 +89,8 @@ const afterStoreSetup = ({ store, i18n }) => {
|
||||
copyInstanceOption('noAttachmentLinks')
|
||||
copyInstanceOption('showFeaturesPanel')
|
||||
|
||||
if ((config.chatDisabled)) {
|
||||
if (config.chatDisabled) {
|
||||
store.dispatch('disableChat')
|
||||
} else {
|
||||
store.dispatch('initializeSocket')
|
||||
}
|
||||
|
||||
return store.dispatch('setTheme', config['theme'])
|
||||
|
@ -1,12 +1,16 @@
|
||||
const chat = {
|
||||
state: {
|
||||
messages: [],
|
||||
channel: {state: ''}
|
||||
channel: {state: ''},
|
||||
socket: null
|
||||
},
|
||||
mutations: {
|
||||
setChannel (state, channel) {
|
||||
state.channel = channel
|
||||
},
|
||||
setSocket (state, socket) {
|
||||
state.socket = socket
|
||||
},
|
||||
addMessage (state, message) {
|
||||
state.messages.push(message)
|
||||
state.messages = state.messages.slice(-19, 20)
|
||||
@ -16,8 +20,12 @@ const chat = {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
disconnectFromChat (store) {
|
||||
store.state.socket.disconnect()
|
||||
},
|
||||
initializeChat (store, socket) {
|
||||
const channel = socket.channel('chat:public')
|
||||
store.commit('setSocket', socket)
|
||||
channel.on('new_msg', (msg) => {
|
||||
store.commit('addMessage', msg)
|
||||
})
|
||||
|
@ -292,6 +292,7 @@ const users = {
|
||||
|
||||
logout (store) {
|
||||
store.commit('clearCurrentUser')
|
||||
store.dispatch('disconnectFromChat')
|
||||
store.commit('setToken', false)
|
||||
store.dispatch('stopFetching', 'friends')
|
||||
store.commit('setBackendInteractor', backendInteractorService())
|
||||
@ -321,6 +322,9 @@ const users = {
|
||||
|
||||
if (user.token) {
|
||||
store.dispatch('setWsToken', user.token)
|
||||
|
||||
// Initialize the chat socket.
|
||||
store.dispatch('initializeSocket')
|
||||
}
|
||||
|
||||
// Start getting fresh posts.
|
||||
|
Loading…
Reference in New Issue
Block a user