diff options
| author | Tusooa Zhu <tusooa@kazv.moe> | 2022-04-06 17:06:41 -0400 |
|---|---|---|
| committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-04-06 17:17:47 -0400 |
| commit | 4ddb6189dc09e03aba5e3da1d2dd2e06e7020b24 (patch) | |
| tree | 51a979cf2795b9bbb17517db64e8ec36e0fde56f /src/modules/shout.js | |
| parent | 0e56ac1c2ba198cd6c91586803758ed0e88cab38 (diff) | |
Fix no reactivity on vuex 4 values
Diffstat (limited to 'src/modules/shout.js')
| -rw-r--r-- | src/modules/shout.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/modules/shout.js b/src/modules/shout.js index 507a4d83..88aefbfe 100644 --- a/src/modules/shout.js +++ b/src/modules/shout.js @@ -1,7 +1,8 @@ const shout = { state: { messages: [], - channel: { state: '' } + channel: { state: '' }, + joined: false }, mutations: { setChannel (state, channel) { @@ -13,11 +14,23 @@ const shout = { }, setMessages (state, messages) { state.messages = messages.slice(-19, 20) + }, + setJoined (state, joined) { + state.joined = joined } }, actions: { initializeShout (store, socket) { 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) => { store.commit('addMessage', msg) }) |
