Call disambiguate on update/map
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
bcb46fc54a
commit
ef40027502
1 changed files with 11 additions and 3 deletions
|
@ -1,12 +1,14 @@
|
|||
import {ViewModel} from "../../ViewModel.js";
|
||||
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
||||
import {createMemberComparator} from "./comparator.js";
|
||||
import {Disambiguator} from "./disambiguator.js";
|
||||
|
||||
export class MemberListViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
||||
.sortValues(createMemberComparator(options.powerLevels));
|
||||
this.nameDisambiguator = new Disambiguator();
|
||||
}
|
||||
|
||||
_filterJoinedMembers(members) {
|
||||
|
@ -14,10 +16,16 @@ export class MemberListViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
_mapTileViewModels(members) {
|
||||
const mapper = (member, emitUpdate) => {
|
||||
return new MemberTileViewModel(this.childOptions({member, emitUpdate}));
|
||||
const mapper = (member, emitChange) => {
|
||||
const vm = new MemberTileViewModel(this.childOptions({member, emitChange}));
|
||||
this.nameDisambiguator.disambiguate(vm);
|
||||
return vm;
|
||||
}
|
||||
const updater = (vm, params, newMember) => vm.updateFrom(newMember);
|
||||
const updater = (vm, params, newMember) => {
|
||||
vm.updateFrom(newMember);
|
||||
this.nameDisambiguator.disambiguate(vm);
|
||||
};
|
||||
return members.mapValues(mapper, updater);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue