forked from mystiq/hydrogen-web
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 {ViewModel} from "../../ViewModel.js";
|
||||||
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
||||||
import {createMemberComparator} from "./comparator.js";
|
import {createMemberComparator} from "./comparator.js";
|
||||||
|
import {Disambiguator} from "./disambiguator.js";
|
||||||
|
|
||||||
export class MemberListViewModel extends ViewModel {
|
export class MemberListViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
||||||
.sortValues(createMemberComparator(options.powerLevels));
|
.sortValues(createMemberComparator(options.powerLevels));
|
||||||
|
this.nameDisambiguator = new Disambiguator();
|
||||||
}
|
}
|
||||||
|
|
||||||
_filterJoinedMembers(members) {
|
_filterJoinedMembers(members) {
|
||||||
|
@ -14,10 +16,16 @@ export class MemberListViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_mapTileViewModels(members) {
|
_mapTileViewModels(members) {
|
||||||
const mapper = (member, emitUpdate) => {
|
const mapper = (member, emitChange) => {
|
||||||
return new MemberTileViewModel(this.childOptions({member, emitUpdate}));
|
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);
|
return members.mapValues(mapper, updater);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue