Alexander Rose 2 years ago
parent
commit
26345bfa50

+ 4 - 2
src/mol-plugin/behavior/dynamic/custom-props/structure-info.ts

@@ -53,12 +53,14 @@ export const StructureInfo = PluginBehavior.create({
         }
 
         private setModelMaxIndex() {
-            const maxIndex = this.maxModelIndex;
+            const value = this.maxModelIndex;
             const cells = this.ctx.state.data.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Model));
             for (const c of cells) {
                 const m = c.obj?.data;
                 if (m) {
-                    Model.MaxIndex.set(m, { value: maxIndex }, maxIndex);
+                    if (Model.MaxIndex.get(m).value !== value) {
+                        Model.MaxIndex.set(m, { value }, value);
+                    }
                 }
             }
         }

+ 1 - 1
src/mol-theme/color/model-index.ts

@@ -31,7 +31,7 @@ export function ModelIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<Mod
 
     if (ctx.structure) {
         // max-index is the same for all models
-        const size = (Model.MaxIndex.get(ctx.structure.models[0])?.value || -1) + 1;
+        const size = (Model.MaxIndex.get(ctx.structure.models[0]).value ?? -1) + 1;
 
         const palette = getPalette(size, props);
         legend = palette.legend;