mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Settle on MappedMap
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
f41c835e91
commit
404129f60e
@ -1,13 +1,12 @@
|
||||
import {ViewModel} from "../../ViewModel.js";
|
||||
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
||||
import {createMemberComparator} from "./comparator.js";
|
||||
import {MappedList} from "../../../observable/list/MappedList.js";
|
||||
|
||||
export class MemberListViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members)
|
||||
.sortValues(createMemberComparator(options.powerLevels)));
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
||||
.sortValues(createMemberComparator(options.powerLevels));
|
||||
}
|
||||
|
||||
_filterJoinedMembers(members) {
|
||||
@ -15,10 +14,10 @@ export class MemberListViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
_mapTileViewModels(members) {
|
||||
const mapper = (member) => {
|
||||
return new MemberTileViewModel(this.childOptions({member}));
|
||||
const mapper = (member, emitUpdate) => {
|
||||
return new MemberTileViewModel(this.childOptions({member, emitUpdate}));
|
||||
}
|
||||
const updater = (vm, params, newMember) => vm.updateFrom(newMember);
|
||||
return new MappedList(members, mapper, updater);
|
||||
return members.mapValues(mapper, updater);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user