mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +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);
|
||||
break;
|
||||
|
||||
case "user_joined_call":
|
||||
SendEvent("userJoinedCall", msg.data);
|
||||
break;
|
||||
|
||||
case "user_left_call":
|
||||
SendEvent("userLeftCall", msg.data);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error("WS Unspported kind of message!", msg);
|
||||
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", () => {
|
||||
// Close all the current conversations
|
||||
OpenConversations.forEach((v) => v.Close(false))
|
||||
|
@ -185,11 +185,27 @@ class CallWindow extends CustomEvents {
|
||||
async AddMember(userID) {
|
||||
|
||||
// Apply user information
|
||||
createElem2({
|
||||
const el = createElem2({
|
||||
appendTo: this.membersArea,
|
||||
type: "span",
|
||||
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