mirror of
https://github.com/beatriceo/polyglot.git
synced 2025-10-25 18:52:11 +00:00
Romain added hangup
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user