Skip to content
Snippets Groups Projects
Commit e13df4dc authored by David Sehnal's avatar David Sehnal
Browse files

mol-state: refactored transform state handling

parent 92412f21
No related branches found
No related tags found
No related merge requests found
...@@ -53,9 +53,10 @@ class StateTreeNode extends PluginUIComponent<{ cell: StateObjectCell, depth: nu ...@@ -53,9 +53,10 @@ class StateTreeNode extends PluginUIComponent<{ cell: StateObjectCell, depth: nu
componentDidMount() { componentDidMount() {
this.subscribe(this.plugin.events.state.cell.stateUpdated, e => { this.subscribe(this.plugin.events.state.cell.stateUpdated, e => {
if (this.props.cell === e.cell && this.is(e) && e.state.cells.has(this.ref)) { if (this.props.cell === e.cell && this.is(e) && e.state.cells.has(this.ref)) {
if (!!this.props.cell.state.isCollapsed !== this.state.isCollapsed) { this.forceUpdate();
this.setState({ isCollapsed: !!e.cell.state.isCollapsed }); // if (!!this.props.cell.state.isCollapsed !== this.state.isCollapsed) {
} // this.setState({ isCollapsed: !!e.cell.state.isCollapsed });
// }
} }
}); });
...@@ -83,7 +84,9 @@ class StateTreeNode extends PluginUIComponent<{ cell: StateObjectCell, depth: nu ...@@ -83,7 +84,9 @@ class StateTreeNode extends PluginUIComponent<{ cell: StateObjectCell, depth: nu
render() { render() {
const cell = this.props.cell; const cell = this.props.cell;
if (!cell || cell.obj === StateObject.Null) return null; if (!cell || cell.obj === StateObject.Null) {
return null;
}
const cellState = cell.state; const cellState = cell.state;
const showLabel = cell.status !== 'ok' || !cell.state.isGhost; const showLabel = cell.status !== 'ok' || !cell.state.isGhost;
......
...@@ -52,6 +52,7 @@ namespace Transform { ...@@ -52,6 +52,7 @@ namespace Transform {
export function assignState(a: State, b?: Partial<State>): boolean { export function assignState(a: State, b?: Partial<State>): boolean {
if (!b) return false; if (!b) return false;
let changed = false; let changed = false;
for (const k of Object.keys(b)) { for (const k of Object.keys(b)) {
const s = (b as any)[k], t = (a as any)[k]; const s = (b as any)[k], t = (a as any)[k];
...@@ -59,6 +60,12 @@ namespace Transform { ...@@ -59,6 +60,12 @@ namespace Transform {
changed = true; changed = true;
(a as any)[k] = s; (a as any)[k] = s;
} }
for (const k of Object.keys(a)) {
const s = (b as any)[k], t = (a as any)[k];
if (!!s === !!t) continue;
changed = true;
(a as any)[k] = s;
}
return changed; return changed;
} }
......
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