Fix no reactivity on vuex 4 values
This commit is contained in:
parent
0e56ac1c2b
commit
4ddb6189dc
@ -65,7 +65,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
shout () { return this.$store.state.shout.channel.state === 'joined' },
|
shout () { return this.$store.state.shout.joined },
|
||||||
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
|
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
|
||||||
showInstanceSpecificPanel () {
|
showInstanceSpecificPanel () {
|
||||||
return this.$store.state.instance.showInstanceSpecificPanel &&
|
return this.$store.state.instance.showInstanceSpecificPanel &&
|
||||||
|
@ -49,7 +49,7 @@ const SideDrawer = {
|
|||||||
currentUser () {
|
currentUser () {
|
||||||
return this.$store.state.users.currentUser
|
return this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
shout () { return this.$store.state.shout.channel.state === 'joined' },
|
shout () { return this.$store.state.shout.joined },
|
||||||
unseenNotifications () {
|
unseenNotifications () {
|
||||||
return unseenNotificationsFromStore(this.$store)
|
return unseenNotificationsFromStore(this.$store)
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const shout = {
|
const shout = {
|
||||||
state: {
|
state: {
|
||||||
messages: [],
|
messages: [],
|
||||||
channel: { state: '' }
|
channel: { state: '' },
|
||||||
|
joined: false
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setChannel (state, channel) {
|
setChannel (state, channel) {
|
||||||
@ -13,11 +14,23 @@ const shout = {
|
|||||||
},
|
},
|
||||||
setMessages (state, messages) {
|
setMessages (state, messages) {
|
||||||
state.messages = messages.slice(-19, 20)
|
state.messages = messages.slice(-19, 20)
|
||||||
|
},
|
||||||
|
setJoined (state, joined) {
|
||||||
|
state.joined = joined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
initializeShout (store, socket) {
|
initializeShout (store, socket) {
|
||||||
const channel = socket.channel('chat:public')
|
const channel = socket.channel('chat:public')
|
||||||
|
channel.joinPush.receive('ok', () => {
|
||||||
|
store.commit('setJoined', true)
|
||||||
|
})
|
||||||
|
channel.onClose(() => {
|
||||||
|
store.commit('setJoined', false)
|
||||||
|
})
|
||||||
|
channel.onError(() => {
|
||||||
|
store.commit('setJoined', false)
|
||||||
|
})
|
||||||
channel.on('new_msg', (msg) => {
|
channel.on('new_msg', (msg) => {
|
||||||
store.commit('addMessage', msg)
|
store.commit('addMessage', msg)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user