From 82502e3bb18f21dc72ec7ac9b84f4b1354b93776 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 18 Apr 2023 18:02:52 +0530 Subject: [PATCH] Fix bug The verification panel would only render correctly once. This was due to a race in the right panel navigation code. --- .../session/rightpanel/RightPanelViewModel.js | 13 ++++++++----- src/matrix/verification/SAS/channel/RoomChannel.ts | 1 + .../web/ui/session/rightpanel/RightPanelView.js | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/domain/session/rightpanel/RightPanelViewModel.js b/src/domain/session/rightpanel/RightPanelViewModel.js index 36d8213d..474d3cbb 100644 --- a/src/domain/session/rightpanel/RightPanelViewModel.js +++ b/src/domain/session/rightpanel/RightPanelViewModel.js @@ -77,14 +77,17 @@ export class RightPanelViewModel extends ViewModel { }); } - _hookUpdaterToSegment(segment, viewmodel, argCreator, failCallback) { + async _hookUpdaterToSegment(segment, ViewModel, argCreator, failCallback) { const observable = this.navigation.observe(segment); - const updater = this._setupUpdater(segment, viewmodel, argCreator, failCallback); + const updater = await this._setupUpdater(segment, ViewModel, argCreator, failCallback); this.track(observable.subscribe(updater)); } - _setupUpdater(segment, viewmodel, argCreator, failCallback) { + async _setupUpdater(segment, ViewModel, argCreator, failCallback) { const updater = async (skipDispose = false) => { + if (this._activeViewModel instanceof ViewModel) { + return; + } if (!skipDispose) { this._activeViewModel = this.disposeTracked(this._activeViewModel); } @@ -95,11 +98,11 @@ export class RightPanelViewModel extends ViewModel { failCallback(); return; } - this._activeViewModel = this.track(new viewmodel(this.childOptions(args))); + this._activeViewModel = this.track(new ViewModel(this.childOptions(args))); } this.emitChange("activeViewModel"); }; - updater(true); + await updater(true); return updater; } diff --git a/src/matrix/verification/SAS/channel/RoomChannel.ts b/src/matrix/verification/SAS/channel/RoomChannel.ts index 97fef1d4..f0b7f1d0 100644 --- a/src/matrix/verification/SAS/channel/RoomChannel.ts +++ b/src/matrix/verification/SAS/channel/RoomChannel.ts @@ -183,6 +183,7 @@ export class RoomChannel extends Disposables implements IChannel { async cancelVerification(cancellationType: CancelReason) { await this.log.wrap("RoomChannel.cancelVerification", async log => { + log.log({ reason: messageFromErrorType[cancellationType] }); if (this.isCancelled) { throw new VerificationCancelledError(); } diff --git a/src/platform/web/ui/session/rightpanel/RightPanelView.js b/src/platform/web/ui/session/rightpanel/RightPanelView.js index 21244a39..738f8cb6 100644 --- a/src/platform/web/ui/session/rightpanel/RightPanelView.js +++ b/src/platform/web/ui/session/rightpanel/RightPanelView.js @@ -56,7 +56,7 @@ class ButtonsView extends TemplateView { className: { "back": true, "button-utility": true, - "hide": !vm.activeViewModel.shouldShowBackButton + "hide": (vm) => !vm.activeViewModel.shouldShowBackButton }, onClick: () => vm.showPreviousPanel()}), t.button({className: "close button-utility", onClick: () => vm.closePanel()}) ]);