diff options
| author | Roger Braun <rbraun@Bobble.local> | 2017-12-05 11:47:10 +0100 |
|---|---|---|
| committer | Roger Braun <rbraun@Bobble.local> | 2017-12-05 11:47:10 +0100 |
| commit | 27be1e0fa3a9779a624012a8528801679721cb40 (patch) | |
| tree | 70fa1a9543b13575119f3443657b2ffe08e99ccf /src/components/chat/chat.js | |
| parent | 0e51fac2b24c752513afe65736e98eb5fb5ec3af (diff) | |
Move chat to own module.
Diffstat (limited to 'src/components/chat/chat.js')
| -rw-r--r-- | src/components/chat/chat.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 3b84bd3d..fc942a30 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -1,23 +1,18 @@ const chat = { data () { return { - messages: [], currentMessage: '', - socket: this.$store.state.users.socket, channel: null } }, - created () { - this.channel = this.socket.channel('chat:public') - this.channel.on('new_msg', (msg) => { - this.messages.push(msg) - this.messages = this.messages.slice(-19, 20) - }) - this.channel.join() + computed: { + messages () { + return this.$store.state.chat.messages + } }, methods: { submit(message) { - this.channel.push('new_msg', {text: message}, 10000) + this.$store.state.chat.channel.push('new_msg', {text: message}, 10000) this.currentMessage = ''; } } |
