added autoclick on join room

This commit is contained in:
Beatrice Olivera 2018-08-31 21:24:38 +01:00
parent fbde469f45
commit a7d4422f3a
3 changed files with 9 additions and 9 deletions

View File

@ -24,19 +24,13 @@ App.cable.subscriptions.create({
// console.log(userId) // console.log(userId)
console.log("received broadcast") console.log("received broadcast")
// console.log(data.body) // console.log(data.body)
if (data.head === 302 && data.body["caller"] === userId && data.path ) { if (data.head === 302 && data.body["caller"] === userId && data.path) {
window.location.pathname = data.path window.location.pathname = data.path
} else if (data["message"]["user_id"] === userId) { } else if (data["message"]["user_id"] === userId) { // Some error appears here but it is not fatal
console.log("TRIGGER MODAL") console.log("TRIGGER MODAL")
const acceptButton = document.getElementById('accept-button') const acceptButton = document.getElementById('accept-button')
acceptButton.style.display = "block" acceptButton.style.display = "block"
// const receiveCall = document.getElementById('receive-call')
// receiveCall.dataset.toggle = 'modal'
// receiveCall.dataset.target ='#calleeModal'
// console.log(receiveCall)
// const calleeModal = document.getElementById('calleeModal')
// calleeModal.modal("show")
chatRoomId = data["message"]["chat_room_id"] chatRoomId = data["message"]["chat_room_id"]
console.log(`user with id: ${userId} needs to subscribe to chatroom ${[chatRoomId]}`) console.log(`user with id: ${userId} needs to subscribe to chatroom ${[chatRoomId]}`)
} else { } else {

View File

@ -207,3 +207,9 @@ const joinButton = document.getElementById("join-btn")
joinButton.addEventListener('click', event => { joinButton.addEventListener('click', event => {
handleJoinSession() handleJoinSession()
}) })
// WARNING: COMPLETELY HACKISH SOLUTION --> MUST INTRODUCE SOME SORT OF DELAY!
setTimeout(function() {
joinButton.click()
}, 5000);

View File

@ -1,4 +1,4 @@
<button id="join-btn" data-room="<%= @chat_room.id %>">Join Room</button> <div id="join-btn" data-room="<%= @chat_room.id %>"></div>
<!-- <div id="join-session" onclick="handleJoinSession()" data-room="<%= @chat_room.id %>"> --> <!-- <div id="join-session" onclick="handleJoinSession()" data-room="<%= @chat_room.id %>"> -->
<div id="chatroom-hook" data-chatroom-id='<%= @chat_room.id %>'></div> <div id="chatroom-hook" data-chatroom-id='<%= @chat_room.id %>'></div>