added state modifier
This commit is contained in:
1 parent
5f486a5f89
commit
32fd7f2dff
14 files changed
+199
-182
No files matched your search
@@ -14,14 +14,14 @@ export default function AutomationEditor({ automation }: Props) {
|
||||
|
||||
// helper state functions
|
||||
const addNode = <T extends types.AutomationNodeType>(node_type: T, node: types.AutomationNodeTypes[T]) => {
|
||||
const nodes: types.AutomationNode[] = state[node_type];
|
||||
const nodes: types.AutomationNode<T>[] = state[node_type];
|
||||
setState({
|
||||
...state,
|
||||
[node_type]: nodes.concat([node as any])
|
||||
});
|
||||
}
|
||||
const removeNode = <T extends types.AutomationNodeType>(node_type: T, node_id: number) => {
|
||||
const nodes: types.AutomationNode[] = state[node_type];
|
||||
const nodes: types.AutomationNode<T>[] = state[node_type];
|
||||
setState({
|
||||
...state,
|
||||
[node_type]: nodes
|
||||
@@ -35,8 +35,8 @@ export default function AutomationEditor({ automation }: Props) {
|
||||
});
|
||||
}
|
||||
// helper element functions
|
||||
const makeChild = (node_type: types.AutomationNodeType) => {
|
||||
const nodes: types.AutomationNode[] = state[node_type];
|
||||
const makeChild = <T extends types.AutomationNodeType>(node_type: T) => {
|
||||
const nodes: types.AutomationNode<T>[] = state[node_type];
|
||||
return [
|
||||
<div className="automation-box--elm-list" key="list">
|
||||
{state[node_type].map((n, i) => (
|
||||
|
||||
Reference in new issue
Block a user