mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Automatically update the list of members of the call
This commit is contained in:
parent
40c895870f
commit
e46f8a36a7
@ -221,6 +221,14 @@ class UserWebSocket {
|
|||||||
SendEvent("commentDeleted", msg.data);
|
SendEvent("commentDeleted", msg.data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "user_joined_call":
|
||||||
|
SendEvent("userJoinedCall", msg.data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "user_left_call":
|
||||||
|
SendEvent("userLeftCall", msg.data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error("WS Unspported kind of message!", msg);
|
console.error("WS Unspported kind of message!", msg);
|
||||||
break;
|
break;
|
||||||
|
@ -76,6 +76,21 @@ class CallsController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener("userJoinedCall", (e) => {
|
||||||
|
const detail = e.detail;
|
||||||
|
|
||||||
|
if(OpenConversations.has(detail.callID))
|
||||||
|
OpenConversations.get(detail.callID).AddMember(detail.userID)
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener("userLeftCall", (e) => {
|
||||||
|
const detail = e.detail;
|
||||||
|
|
||||||
|
if(OpenConversations.has(detail.callID))
|
||||||
|
OpenConversations.get(detail.callID).RemoveMember(detail.userID)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("wsClosed", () => {
|
document.addEventListener("wsClosed", () => {
|
||||||
// Close all the current conversations
|
// Close all the current conversations
|
||||||
OpenConversations.forEach((v) => v.Close(false))
|
OpenConversations.forEach((v) => v.Close(false))
|
||||||
|
@ -185,11 +185,27 @@ class CallWindow extends CustomEvents {
|
|||||||
async AddMember(userID) {
|
async AddMember(userID) {
|
||||||
|
|
||||||
// Apply user information
|
// Apply user information
|
||||||
createElem2({
|
const el = createElem2({
|
||||||
appendTo: this.membersArea,
|
appendTo: this.membersArea,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: (await user(userID)).fullName
|
innerHTML: (await user(userID)).fullName
|
||||||
});
|
});
|
||||||
|
el.setAttribute("data-call-member-name-id", userID)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from a call
|
||||||
|
*
|
||||||
|
* @param {number} userID The ID of the target user
|
||||||
|
*/
|
||||||
|
async RemoveMember(userID) {
|
||||||
|
|
||||||
|
// Remove user name
|
||||||
|
const el = this.membersArea.querySelector("[data-call-member-name-id=\""+userID+"\"]")
|
||||||
|
if(el)
|
||||||
|
el.remove()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user