X-Git-Url: https://git.r.bdr.sh/rbdr/junction/blobdiff_plain/d38261f11a1fa6d922cf1a7a52601c282d0a8527..fa4ef5088fc6db7d20616d6bf48ed1d3e9f9f255:/extension/peers.js?ds=inline diff --git a/extension/peers.js b/extension/peers.js index 2d74fad..2b4e3d6 100644 --- a/extension/peers.js +++ b/extension/peers.js @@ -1,49 +1,43 @@ -'use strict'; - const internals = { peers: {}, createAudioElement(source) { - - const audioElement = document.createElement('audio'); - audioElement.setAttribute('class', 'junction-call-audio'); - audioElement.autoplay = 'autoplay'; + const audioElement = document.createElement("audio"); + audioElement.setAttribute("class", "junction-call-audio"); + audioElement.autoplay = "autoplay"; // WE WILL NOT LOSE TADA SUPPORT - if (typeof source === 'string') { + if (typeof source === "string") { audioElement.src = source; - } - else { - audoElement.srcObject = source; + } else { + audioElement.srcObject = source; } - document.querySelector('body').appendChild(audioElement); + document.querySelector("body").appendChild(audioElement); return audioElement; - } + }, }; -module.exports = { +export default { add(id, source) { - internals.peers[id] && this.remove(id); - internals.peers[id] = internals.createAudioElement(source) + internals.peers[id] = internals.createAudioElement(source); }, remove(id) { - internals.peers[id] && internals.peers[id].remove(); delete internals.peers[id]; }, count() { - return Object.keys(internals.peers).length; }, reset() { - internals.peers = {}; - document.querySelectorAll('.junction-call-audio').forEach((audioElement) => audioElement.remove()); - } + document + .querySelectorAll(".junction-call-audio") + .forEach((audioElement) => audioElement.remove()); + }, };