Skip to content

Commit c81e938

Browse files
Keep the roster sorted (#3044)
1 parent 4fb9f47 commit c81e938

File tree

1 file changed

+9
-0
lines changed
  • demos/browser/app/meetingV2/component

1 file changed

+9
-0
lines changed

demos/browser/app/meetingV2/component/Roster.ts

+9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export default class Roster {
9292

9393
attendeeElement.className = 'list-group-item d-flex align-items-center gap-2';
9494
attendeeElement.id = Roster.ATTENDEE_ELEMENT_PREFIX + attendeeId;
95+
attendeeElement.setAttribute("data-sort-key", attendeeName);
9596
if (allowAttendeeCapabilities) {
9697
attendeeElement.classList.add('ps-2');
9798
attendeeElement.appendChild(attendeeCheckbox);
@@ -101,6 +102,14 @@ export default class Roster {
101102

102103
const containerElement: HTMLUListElement = this.getContainerElement();
103104
containerElement.appendChild(attendeeElement);
105+
this.sortRoster();
106+
}
107+
108+
private sortRoster() {
109+
const containerElement: HTMLUListElement = this.getContainerElement();
110+
const sortedChildren = Array.from(containerElement.children)
111+
.sort((a, b) => a.getAttribute("data-sort-key")!.localeCompare(b.getAttribute("data-sort-key")!));
112+
sortedChildren.forEach(child => containerElement.appendChild(child));
104113
}
105114

106115
/**

0 commit comments

Comments
 (0)