simplify rollback
This commit is contained in:
parent
ebae0afc81
commit
0a9dbd454f
4 changed files with 57 additions and 26 deletions
|
|
@ -14,17 +14,16 @@ export interface CallBlockState {
|
|||
fn: EditorState;
|
||||
input: EditorState;
|
||||
resolved: undefined | Dynamic;
|
||||
rollback: EditorState;
|
||||
}
|
||||
|
||||
interface CallBlockProps extends State2Props<CallBlockState> {
|
||||
onResolve: (resolved: EditorState) => void;
|
||||
}
|
||||
|
||||
export function CallBlock({ state: {kind, env, fn, input, resolved, rollback }, setState, onResolve }: CallBlockProps) {
|
||||
export function CallBlock({ state: {kind, env, fn, input, resolved }, setState, onResolve }: CallBlockProps) {
|
||||
const [unifyError, setUnifyError] = useState<UnifyError | undefined>(undefined);
|
||||
const setResolved = (resolved?: Dynamic) => {
|
||||
setState({kind, env, fn, input, resolved, rollback});
|
||||
setState({kind, env, fn, input, resolved});
|
||||
}
|
||||
|
||||
const makeTheCall = (input, fn) => {
|
||||
|
|
@ -34,7 +33,7 @@ export function CallBlock({ state: {kind, env, fn, input, resolved, rollback },
|
|||
setResolved(outputResolved);
|
||||
console.log("onResolve callblock..")
|
||||
onResolve({
|
||||
kind, env, fn, input, resolved: outputResolved, rollback
|
||||
kind, env, fn, input, resolved: outputResolved
|
||||
});
|
||||
setUnifyError(undefined);
|
||||
}
|
||||
|
|
@ -44,16 +43,16 @@ export function CallBlock({ state: {kind, env, fn, input, resolved, rollback },
|
|||
}
|
||||
setUnifyError(e);
|
||||
onResolve({
|
||||
kind, env, fn, input, resolved: undefined, rollback
|
||||
kind, env, fn, input, resolved: undefined
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const setFn = (fn: EditorState) => {
|
||||
setState({kind, env, fn, input, resolved, rollback});
|
||||
setState({kind, env, fn, input, resolved});
|
||||
}
|
||||
const setInput = (input: EditorState) => {
|
||||
setState({kind, env, fn, input, resolved, rollback});
|
||||
setState({kind, env, fn, input, resolved});
|
||||
}
|
||||
const onFnResolve = (fnState) => {
|
||||
console.log('my fn resolved')
|
||||
|
|
@ -64,7 +63,7 @@ export function CallBlock({ state: {kind, env, fn, input, resolved, rollback },
|
|||
// setFn(fnState);
|
||||
setResolved(undefined);
|
||||
onResolve({
|
||||
kind, env, fn: fnState, input, resolved: undefined, rollback
|
||||
kind, env, fn: fnState, input, resolved: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +76,7 @@ export function CallBlock({ state: {kind, env, fn, input, resolved, rollback },
|
|||
// setInput(inputState);
|
||||
setResolved(undefined);
|
||||
onResolve({
|
||||
kind, env, fn, input: inputState, resolved: undefined, rollback
|
||||
kind, env, fn, input: inputState, resolved: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -85,11 +84,7 @@ export function CallBlock({ state: {kind, env, fn, input, resolved, rollback },
|
|||
|
||||
}
|
||||
const onInputCancel = () => {
|
||||
// we become what we were before we became a CallBlock
|
||||
if (rollback) {
|
||||
setState(rollback);
|
||||
focusPrevElement();
|
||||
}
|
||||
setState(fn);
|
||||
}
|
||||
|
||||
const filterCompatibleInputs = ([_name, dynamic]: [string, Dynamic]) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue