Browse Source

mol-plugin-state: do not update interaction params if they didnt change

David Sehnal 5 years ago
parent
commit
5fd28c6cad
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/mol-plugin-state/manager/structure/component.ts

+ 9 - 1
src/mol-plugin-state/manager/structure/component.ts

@@ -80,7 +80,12 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
 
     private async updateInterationProps() {
         for (const s of this.currentStructures) {
+            const interactionParams = InteractionsProvider.getParams(s.cell.obj?.data!);
+            
             if (s.properties) {
+                const params = s.properties.cell.transform.params;
+                if (PD.areEqual(interactionParams, params, this.state.options.interactions)) continue;
+
                 const b = this.dataState.build();
                 b.to(s.properties.cell).update((old: StateTransformer.Params<CustomStructureProperties>) => {
                     arraySetAdd(old.autoAttach, InteractionsProvider.descriptor.name);
@@ -88,7 +93,10 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
                 });
                 await this.plugin.runTask(this.dataState.updateTree(b));
             } else {
-                const params = PD.getDefaultValues(this.plugin.customStructureProperties.getParams(s.cell.obj?.data));
+                const pd = this.plugin.customStructureProperties.getParams(s.cell.obj?.data);
+                const params = PD.getDefaultValues(pd);
+                if (PD.areEqual(interactionParams, params.properties[InteractionsProvider.descriptor.name], this.state.options.interactions)) continue;
+
                 arraySetAdd(params.autoAttach, InteractionsProvider.descriptor.name);
                 params.properties[InteractionsProvider.descriptor.name] = this.state.options.interactions;
                 await this.plugin.builders.structure.insertStructureProperties(s.cell, params);