Rename variable

This commit is contained in:
Pierre HUBERT 2020-04-12 17:10:44 +02:00
parent a1efa39654
commit c022187c02

View File

@ -7,7 +7,7 @@
/** /**
* @type {Map<number, CallWindow>} * @type {Map<number, CallWindow>}
*/ */
let OpenConversations = new Map(); let OpenCalls = new Map();
class CallsController { class CallsController {
@ -17,18 +17,18 @@ class CallsController {
* @param {Conversation} conv Information about the target conversation * @param {Conversation} conv Information about the target conversation
*/ */
static Open(conv) { static Open(conv) {
if(OpenConversations.has(conv.ID) && OpenConversations.get(conv.ID).rootEl.isConnected) if(OpenCalls.has(conv.ID) && OpenCalls.get(conv.ID).rootEl.isConnected)
return; return;
console.info("Open call for conversation " + conv.ID); console.info("Open call for conversation " + conv.ID);
// Create a new window for the conversation // Create a new window for the conversation
const window = new CallWindow(conv); const window = new CallWindow(conv);
OpenConversations.set(conv.ID, window) OpenCalls.set(conv.ID, window)
this.AddToLocalStorage(conv.ID); this.AddToLocalStorage(conv.ID);
window.on("close", () => { window.on("close", () => {
OpenConversations.delete(conv.ID) OpenCalls.delete(conv.ID)
this.RemoveFromLocalStorage(conv.ID) this.RemoveFromLocalStorage(conv.ID)
}) })
} }
@ -79,15 +79,15 @@ class CallsController {
document.addEventListener("userJoinedCall", (e) => { document.addEventListener("userJoinedCall", (e) => {
const detail = e.detail; const detail = e.detail;
if(OpenConversations.has(detail.callID)) if(OpenCalls.has(detail.callID))
OpenConversations.get(detail.callID).AddMember(detail.userID) OpenCalls.get(detail.callID).AddMember(detail.userID)
}) })
document.addEventListener("userLeftCall", (e) => { document.addEventListener("userLeftCall", (e) => {
const detail = e.detail; const detail = e.detail;
if(OpenConversations.has(detail.callID)) if(OpenCalls.has(detail.callID))
OpenConversations.get(detail.callID).RemoveMember(detail.userID) OpenCalls.get(detail.callID).RemoveMember(detail.userID)
}) })
document.addEventListener("newCallSignal", (e) => { document.addEventListener("newCallSignal", (e) => {
@ -100,29 +100,29 @@ document.addEventListener("newCallSignal", (e) => {
candidate: signal candidate: signal
} }
if(OpenConversations.has(detail.callID)) if(OpenCalls.has(detail.callID))
OpenConversations.get(detail.callID).NewSignal(detail.peerID, signal) OpenCalls.get(detail.callID).NewSignal(detail.peerID, signal)
}); });
document.addEventListener("callPeerReady", (e) => { document.addEventListener("callPeerReady", (e) => {
const detail = e.detail; const detail = e.detail;
if(OpenConversations.has(detail.callID)) if(OpenCalls.has(detail.callID))
OpenConversations.get(detail.callID).PeerReady(detail.peerID) OpenCalls.get(detail.callID).PeerReady(detail.peerID)
}) })
document.addEventListener("wsClosed", () => { document.addEventListener("wsClosed", () => {
// Close all the current conversations // Close all the current conversations
OpenConversations.forEach((v) => v.Close(false)) OpenCalls.forEach((v) => v.Close(false))
OpenConversations.clear(); OpenCalls.clear();
}) })
document.addEventListener("openPage", () => { document.addEventListener("openPage", () => {
CallsController.GetListLocalStorage().forEach(async c => { CallsController.GetListLocalStorage().forEach(async c => {
if(!OpenConversations.has(c)) if(!OpenCalls.has(c))
CallsController.Open(await getSingleConversation(c)) CallsController.Open(await getSingleConversation(c))
}) })
}) })