Sort memberlist using powerlevel

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-06-18 13:16:23 +05:30
parent 3e23392a0e
commit a9ff6ab026
2 changed files with 4 additions and 6 deletions

View file

@ -1,15 +1,12 @@
import {ViewModel} from "../../ViewModel.js";
import {MemberTileViewModel} from "./MemberTileViewModel.js";
function comparator(member, otherMember) {
return member.displayName?.localeCompare(otherMember.displayName);
}
import {createMemberComparator} from "./comparator.js";
export class MemberListViewModel extends ViewModel {
constructor(options) {
super(options);
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
.sortValues(comparator);
.sortValues(createMemberComparator(options.powerLevels));
}
_filterJoinedMembers(members) {

View file

@ -38,8 +38,9 @@ export class RightPanelViewModel extends ViewModel {
if (enable) {
const list = await this._room.loadMemberList();
const members = list.members;
const powerLevels = this._room.powerLevels;
this._memberListViewModel = this.track(
new MemberListViewModel(this.childOptions({members}))
new MemberListViewModel(this.childOptions({members, powerLevels}))
);
}
this.emitChange("memberListViewModel");