From 0819dcb29ef1ad9f46ba25053d06e1366d6fcf49 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 22 Jun 2021 15:52:05 +0530 Subject: [PATCH] Use MappedList instead of MappedMap - MappedList supports an optional updater method Signed-off-by: RMidhunSuresh --- .../session/rightpanel/MemberListViewModel.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/domain/session/rightpanel/MemberListViewModel.js b/src/domain/session/rightpanel/MemberListViewModel.js index 737fb6cf..9f8f382d 100644 --- a/src/domain/session/rightpanel/MemberListViewModel.js +++ b/src/domain/session/rightpanel/MemberListViewModel.js @@ -1,12 +1,13 @@ 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) { @@ -14,8 +15,10 @@ export class MemberListViewModel extends ViewModel { } _mapTileViewModels(members) { - return members.mapValues((member, emitChange) => { - return new MemberTileViewModel(this.childOptions({member, emitChange})); - }); + const mapper = (member) => { + return new MemberTileViewModel(this.childOptions({member})); + } + const updater = (vm, params, newMember) => vm.updateFrom(newMember); + return new MappedList(members, mapper, updater); } }