Skip to content
Snippets Groups Projects
Commit 4a692b9a authored by Alexander Rose's avatar Alexander Rose
Browse files

ensure applicable repr types are up-to-date

parent 0094f800
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ import { VisualQuality, VisualQualityOptions } from '../../../mol-geo/geometry/b
import { StructureRepresentationPresets as P } from '../../util/structure-representation-helper';
import { camelCaseToWords } from '../../../mol-util/string';
import { CollapsableControls } from '../base';
import { StateSelection } from '../../../mol-state';
import { StateSelection, StateObject } from '../../../mol-state';
import { PluginStateObject } from '../../state/objects';
abstract class BaseStructureRepresentationControls extends PluginUIComponent {
......@@ -28,7 +28,7 @@ abstract class BaseStructureRepresentationControls extends PluginUIComponent {
return this.plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure)).map(s => s.obj!.data)
}
/** applicapble types */
/** applicable types */
private get types() {
const types: [string, string][] = []
const structures = this.structures
......@@ -40,6 +40,18 @@ abstract class BaseStructureRepresentationControls extends PluginUIComponent {
return types
}
private forceUpdateIfStructure = (obj?: StateObject) => {
if (obj && obj.type === PluginStateObject.Molecule.Structure.type) {
this.forceUpdate()
}
}
componentDidMount() {
this.subscribe(this.plugin.events.state.object.created, ({ obj }) => this.forceUpdateIfStructure(obj));
this.subscribe(this.plugin.events.state.object.removed, ({ obj }) => this.forceUpdateIfStructure(obj));
}
show = (value: string) => {
this.plugin.helpers.structureRepresentation.set('add', value, this.lociGetter)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment