FIX[WebApp]: Simplify loading logic of workbook (#87)

Note that previously the model would have been fetched twice
This commit is contained in:
Nicolás Hatcher Andrés
2024-08-24 06:59:19 +02:00
committed by GitHub
parent 40aa8bebaf
commit 83a4431417

View File

@@ -24,20 +24,17 @@ function App() {
const model_bytes = new Uint8Array( const model_bytes = new Uint8Array(
await (await fetch(`./${modelName}`)).arrayBuffer(), await (await fetch(`./${modelName}`)).arrayBuffer(),
); );
const _model = Model.from_bytes(model_bytes); setModel(Model.from_bytes(model_bytes));
if (!model) setModel(_model);
} catch (e) { } catch (e) {
const _model = new Model("en", "UTC"); setModel(new Model("en", "UTC"));
if (!model) setModel(_model);
} }
} else { } else {
const _model = new Model("en", "UTC"); setModel(new Model("en", "UTC"));
if (!model) setModel(_model);
} }
if (!workbookState) setWorkbookState(new WorkbookState()); setWorkbookState(new WorkbookState());
} }
start(); start();
}, [model, workbookState]); }, []);
if (!model || !workbookState) { if (!model || !workbookState) {
return <Loading>Loading</Loading>; return <Loading>Loading</Loading>;