removed comment, cleaned up a function
This commit is contained in:
parent
405c1bf8f3
commit
a46f50dd0f
|
@ -6,13 +6,12 @@ import type { result, errorValue, bindings } from "@quri/squiggle-lang";
|
||||||
|
|
||||||
function resultDefault(
|
function resultDefault(
|
||||||
x: result<bindings, errorValue>,
|
x: result<bindings, errorValue>,
|
||||||
defaul: bindings
|
|
||||||
): bindings {
|
): bindings {
|
||||||
switch (x.tag) {
|
switch (x.tag) {
|
||||||
case "Ok":
|
case "Ok":
|
||||||
return x.value;
|
return x.value;
|
||||||
case "Error":
|
case "Error":
|
||||||
return defaul;
|
return defaultBindings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +30,11 @@ export const SquiggleEditorImportedBindings: React.FC<
|
||||||
SquiggleEditorImportedBindingsProps
|
SquiggleEditorImportedBindingsProps
|
||||||
> = (props) => {
|
> = (props) => {
|
||||||
const [bindingsResult, setBindingsResult] = React.useState({
|
const [bindingsResult, setBindingsResult] = React.useState({
|
||||||
tag: "Ok" as "Ok",
|
tag: "Ok",
|
||||||
value: defaultBindings,
|
value: defaultBindings,
|
||||||
} as result<bindings, errorValue>);
|
} as result<bindings, errorValue>);
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
async function retrieveBindings(fileName: string) {
|
async function retrieveBindings(fileName: string) {
|
||||||
//: Promise<result<bindings, errorValue>> {
|
|
||||||
let contents = await fetch(fileName).then((response) => {
|
let contents = await fetch(fileName).then((response) => {
|
||||||
return response.text();
|
return response.text();
|
||||||
});
|
});
|
||||||
|
@ -44,7 +42,7 @@ export const SquiggleEditorImportedBindings: React.FC<
|
||||||
}
|
}
|
||||||
retrieveBindings(props.bindingsImportFile);
|
retrieveBindings(props.bindingsImportFile);
|
||||||
}, []);
|
}, []);
|
||||||
const deliveredBindings = resultDefault(bindingsResult, {});
|
const deliveredBindings = resultDefault(bindingsResult);
|
||||||
const newProps = replaceBindings(props, deliveredBindings);
|
const newProps = replaceBindings(props, deliveredBindings);
|
||||||
return <SquiggleEditor {...newProps} />;
|
return <SquiggleEditor {...newProps} />;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user