Romain added hangup

This commit is contained in:
Ethan Fraenkel
2018-09-04 14:50:44 +02:00
parent a48f955914
commit 95d0c2f5cd
9 changed files with 51 additions and 3 deletions

View File

@@ -19,9 +19,26 @@ App['chatroom' + chatroomId] = App.cable.subscriptions.create({
connected: () => {
},
received: data => {
if (data.hangUp) {
document.location.pathname = '/contacts'
}
},
disconnected: () => {
document.location.pathname = '/contacts'
}
})
const hangUpIcon = document.querySelector('.fa-hand-paper')
hangUpIcon.addEventListener('click', event => {
fetch(`/chat_rooms/${chatroomId}`, {
method: 'DELETE',
headers: {
'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content
}
})
document.location.pathname = '/contacts'
})
// Testing ActionCable
// const testBtn = document.getElementById('test-btn')
// testBtn.addEventListener('click', event => {