From 64d6db556a0e3a6a0c5fed3dc8a27345962e928f Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:36:39 +0100 Subject: [PATCH] fix updates from call and member classes in VM this fixes this.emitChange sending the update over the collection in the call member VM, which is how updates are subscribed to by the UI. It also adds a callback to the VM for when the member sends an update, so we can check later on if the error on the member has been set. --- src/domain/session/room/CallViewModel.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/domain/session/room/CallViewModel.ts b/src/domain/session/room/CallViewModel.ts index 358b26f0..1080015f 100644 --- a/src/domain/session/room/CallViewModel.ts +++ b/src/domain/session/room/CallViewModel.ts @@ -40,14 +40,19 @@ export class CallViewModel extends ViewModel { constructor(options: Options) { super(options); const callObservable = new EventObservableValue(this.call, "change"); - this.track(callObservable.subscribe(() => { - this.emitChange(); - })); + this.track(callObservable.subscribe(() => this.onUpdate())); const ownMemberViewModelMap = new ObservableValueMap("self", callObservable) .mapValues((call, emitChange) => new OwnMemberViewModel(this.childOptions({call, emitChange})), () => {}); this.memberViewModels = this.call.members .filterValues(member => member.isConnected) - .mapValues(member => new CallMemberViewModel(this.childOptions({member, mediaRepository: this.getOption("room").mediaRepository}))) + .mapValues( + (member, emitChange) => new CallMemberViewModel(this.childOptions({ + member, + emitChange, + mediaRepository: this.getOption("room").mediaRepository + })), + (vm: CallMemberViewModel) => vm.onUpdate(), + ) .join(ownMemberViewModelMap) .sortValues((a, b) => a.compare(b)); this.track(this.memberViewModels.subscribe({ @@ -91,6 +96,9 @@ export class CallViewModel extends ViewModel { return this.getOption("call"); } + private onUpdate() { + } + async hangup() { if (this.call.hasJoined) { await this.call.leave(); @@ -241,6 +249,8 @@ export class CallMemberViewModel extends ViewModel implements ISt return this.member.member.name; } + onUpdate() { + } compare(other: OwnMemberViewModel | CallMemberViewModel): number { if (other instanceof OwnMemberViewModel) { return -other.compare(this);