polyglot/app/javascript/packs/notifications.js

56 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-09-04 10:23:45 +00:00
// import ActionCable from 'actioncable'
// import { triggerCalleeModalEvent } from "./application";
2018-09-04 10:23:45 +00:00
// const triggerCalleeModalEvent = () => {
// $("#calleeModal").modal('show');
// }
// // create App object with key cable == new consumer
// (function() {
// window.App || (window.App = {});
2018-09-04 10:23:45 +00:00
// App.cable = ActionCable.createConsumer();
2018-09-04 10:23:45 +00:00
// }).call(this);
2018-09-04 10:23:45 +00:00
// const userId = parseInt(document.getElementById("my-user-id").dataset["userId"])
// let chatRoomId = null
2018-09-04 10:23:45 +00:00
// App.cable.subscriptions.create({
// channel: 'NotificationsChannel'
// }, {
// connected: () => {
// console.log('Connected to NotificationsChannel')
// },
// received: data => {
// console.log("received broadcast")
2018-09-04 10:23:45 +00:00
// if (data.head === 302 && data.body["caller"] === userId && data.path) {
// window.location.pathname = data.path
// } else if (data["message"]["user_id"] === userId) {
2018-09-03 17:32:03 +00:00
2018-09-04 10:23:45 +00:00
// // DISPLAY ACCEPT BUTTON
// const acceptButton = document.getElementById('accept-button')
// acceptButton.style.display = "block"
2018-09-03 17:32:03 +00:00
2018-09-04 10:23:45 +00:00
// triggerCalleeModalEvent()
// document.getElementById('caller-name').innerHTML = data["message"]["caller_info"]
// document.getElementById('caller-photo').src = data["message"]["caller_photo"]
2018-09-04 10:23:45 +00:00
// chatRoomId = data["message"]["chat_room_id"]
// console.log(`user with id: ${userId} needs to subscribe to chatroom ${[chatRoomId]}`)
// } else {
// console.log(data)
// }
2018-09-03 17:32:03 +00:00
2018-09-04 10:23:45 +00:00
// }
// })
2018-09-04 10:23:45 +00:00
// // Receive information from index.html.erb
// const acceptButton = document.getElementById('accept-button')
2018-09-04 10:23:45 +00:00
// acceptButton.addEventListener('click', event => {
// document.getElementById('chat-room-id').value = chatRoomId
// })