Skip to content
Snippets Groups Projects
Unverified Commit 0d12a9e1 authored by David Sehnal's avatar David Sehnal Committed by GitHub
Browse files

PluginState.setSnapshot fix (#805)

parent ebd3ebe7
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
- Add a uniform color theme for NtC tube that still paints residue and segment dividers in a different color - Add a uniform color theme for NtC tube that still paints residue and segment dividers in a different color
- Fix bond assignments `struct_conn` records referencing waters - Fix bond assignments `struct_conn` records referencing waters
- Fix `PluginState.setSnapshot` triggering unnecessary state updates
## [v3.34.0] - 2023-04-16 ## [v3.34.0] - 2023-04-16
......
/** /**
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2019-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -54,6 +54,12 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone ...@@ -54,6 +54,12 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
return this.currentStructures[0]; return this.currentStructures[0];
} }
// To be used only from PluginState.setSnapshot
_setSnapshotState(options: StructureComponentManager.Options) {
this.updateState({ options });
this.events.optionsUpdated.next(void 0);
}
async setOptions(options: StructureComponentManager.Options) { async setOptions(options: StructureComponentManager.Options) {
const interactionChanged = options.interactions !== this.state.options.interactions; const interactionChanged = options.interactions !== this.state.options.interactions;
this.updateState({ options }); this.updateState({ options });
......
...@@ -76,7 +76,7 @@ class PluginState extends PluginComponent { ...@@ -76,7 +76,7 @@ class PluginState extends PluginComponent {
await this.animation.stop(); await this.animation.stop();
// this needs to go 1st since these changes are already baked into the behavior and data state // this needs to go 1st since these changes are already baked into the behavior and data state
if (snapshot.structureComponentManager?.options) await this.plugin.managers.structure.component.setOptions(snapshot.structureComponentManager?.options); if (snapshot.structureComponentManager?.options) this.plugin.managers.structure.component._setSnapshotState(snapshot.structureComponentManager?.options);
if (snapshot.behaviour) await this.plugin.runTask(this.behaviors.setSnapshot(snapshot.behaviour)); if (snapshot.behaviour) await this.plugin.runTask(this.behaviors.setSnapshot(snapshot.behaviour));
if (snapshot.data) await this.plugin.runTask(this.data.setSnapshot(snapshot.data)); if (snapshot.data) await this.plugin.runTask(this.data.setSnapshot(snapshot.data));
if (snapshot.canvas3d?.props) { if (snapshot.canvas3d?.props) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment