2021-06-11 23:51:55 +05:30
|
|
|
import {ViewModel} from "../../ViewModel.js";
|
|
|
|
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
2021-06-18 13:16:23 +05:30
|
|
|
import {createMemberComparator} from "./comparator.js";
|
2021-06-11 23:51:55 +05:30
|
|
|
|
|
|
|
export class MemberListViewModel extends ViewModel {
|
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
|
|
|
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
2021-06-18 13:16:23 +05:30
|
|
|
.sortValues(createMemberComparator(options.powerLevels));
|
2021-06-11 23:51:55 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_filterJoinedMembers(members) {
|
|
|
|
return members.filterValues(member => member.membership === "join");
|
|
|
|
}
|
|
|
|
|
|
|
|
_mapTileViewModels(members) {
|
|
|
|
return members.mapValues((member, emitChange) => {
|
|
|
|
return new MemberTileViewModel(this.childOptions({member, emitChange}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|