diff --git a/assets/css/components/calls/window.css b/assets/css/components/calls/window.css index 456e751a..3cc330de 100644 --- a/assets/css/components/calls/window.css +++ b/assets/css/components/calls/window.css @@ -40,4 +40,17 @@ .call-window .head a { color: inherit; +} + +.call-window .members-area { + color: white; + font-size: 80%; + text-align: center; + display: flex; + flex-direction: row; + justify-content: center; +} + +.call-window .members-area span { + margin: 0px 5px; } \ No newline at end of file diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js index 5c91f1d0..dd40d8f5 100644 --- a/assets/js/common/shorcuts.js +++ b/assets/js/common/shorcuts.js @@ -197,6 +197,16 @@ function userInfo(userID, force = false) { }); } +/** + * Get information about a user (new User class) + * + * @param {Number} userID target user id + * @returns {Promise} Information about the user + */ +async function user(userID) { + return new User(await userInfo(userID)) +} + /** * Display message on browser console * diff --git a/assets/js/components/calls/window.js b/assets/js/components/calls/window.js index d3f9da01..854de7ef 100644 --- a/assets/js/components/calls/window.js +++ b/assets/js/components/calls/window.js @@ -58,11 +58,31 @@ class CallWindow extends CustomEvents { this.makeWindowDraggable(); + + // Create members area + this.membersArea = createElem2({ + appendTo: this.rootEl, + type: "div", + class: "members-area" + }) + + + // Join the call await ws("calls/join", { convID: this.conv.ID }) + // Get the list of members of the call + const currMembersList = await ws("calls/members", { + callID: this.conv.ID + }) + + // Apply this list of user + for(const user of currMembersList) + if(user != userID()) + await this.AddMember(user) + } catch(e) { console.error(e) notify("Could not initialize call!", "danger"); @@ -156,4 +176,20 @@ class CallWindow extends CustomEvents { if(propagate) this.emitEvent("close"); } + + /** + * Add a member to this call + * + * @param {number} userID The ID of the target member + */ + async AddMember(userID) { + + // Apply user information + createElem2({ + appendTo: this.membersArea, + type: "span", + innerHTML: (await user(userID)).fullName + }); + + } } \ No newline at end of file