From 0c885036b684b1d7b0894f4bed0ede3951f319dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mal=C3=BD?= <michal.maly@ibt.cas.cz> Date: Wed, 9 Nov 2022 14:41:25 +0100 Subject: [PATCH] ReDNATCO plugin stage 31 --- src/apps/rednatco/index.tsx | 6 +++--- src/apps/rednatco/viewer.ts | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/apps/rednatco/index.tsx b/src/apps/rednatco/index.tsx index 560639472..ae047f25b 100644 --- a/src/apps/rednatco/index.tsx +++ b/src/apps/rednatco/index.tsx @@ -155,9 +155,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { } else if (type === 'current-model-number') { return Api.Queries.CurrentModelNumber(this.viewer!.currentModelNumber()); } else if (type === 'selected-step') { - if (this.selectedStep) - return Api.Queries.SelectedStep(this.selectedStep); - return Api.Queries.SelectedStep(); + return this.selectedStep ? Api.Queries.SelectedStep(this.selectedStep) : Api.Queries.SelectedStep(); } assertUnreachable(type); @@ -171,6 +169,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { window.dispatchEvent(new Event('resize')); else if (cmd.type === 'deselect-step') { await this.viewer.actionDeselectStep(this.state.display); + this.selectedStep = void 0; } else if (cmd.type === 'filter') { const ret = await this.viewer.actionApplyFilter(cmd.filter); if (!ret) { @@ -216,6 +215,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { } viewerStepDeselected() { + this.selectedStep = void 0; this.viewer!.actionDeselectStep(this.state.display); ReDNATCOMspApi.event(Api.Events.StepDeselected()); } diff --git a/src/apps/rednatco/viewer.ts b/src/apps/rednatco/viewer.ts index 2edc54ee3..06195b5df 100644 --- a/src/apps/rednatco/viewer.ts +++ b/src/apps/rednatco/viewer.ts @@ -447,7 +447,7 @@ export class ReDNATCOMspViewer { ReDNATCOLociSelectionProvider, { bindings: ReDNATCOLociSelectionBindings, - onDeselected: () => interactCtx.self!.onDeselected(), + onDeselected: () => interactCtx.self!.notifyStepDeselected(), onSelected: (loci) => interactCtx.self!.onLociSelected(loci), } ), @@ -918,17 +918,21 @@ export class ReDNATCOMspViewer { await b.commit(); } - async onDeselected() { + notifyStepDeselected() { this.app.viewerStepDeselected(); } + notifyStepSelected(name: string) { + this.app.viewerStepSelected(name); + } + async onLociSelected(selected: Representation.Loci) { const loci = Loci.normalize(selected.loci, 'two-residues'); if (loci.kind === 'element-loci') { const stepDesc = Step.describe(loci, this.haveMultipleModels); if (stepDesc && this.stepNames.has(stepDesc.name)) - this.app.viewerStepSelected(stepDesc.name); + this.notifyStepSelected(stepDesc.name); } } -- GitLab