add more comments

This commit is contained in:
Abi Raja 2024-07-25 15:15:33 -04:00
parent 59b031e395
commit 7af2e34415

View File

@ -101,6 +101,8 @@ function App() {
} }
}, [settings.generatedCodeConfig, setSettings]); }, [settings.generatedCodeConfig, setSettings]);
// Functions
const reset = () => { const reset = () => {
setAppState(AppState.INITIAL); setAppState(AppState.INITIAL);
setGeneratedCode(""); setGeneratedCode("");
@ -133,12 +135,14 @@ function App() {
doCreate(referenceImages, inputMode); doCreate(referenceImages, inputMode);
}; };
// Used when the user cancels the code generation
const cancelCodeGeneration = () => { const cancelCodeGeneration = () => {
wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE); wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE);
// make sure stop can correct the state even if the websocket is already closed // make sure stop can correct the state even if the websocket is already closed
cancelCodeGenerationAndReset(); cancelCodeGenerationAndReset();
}; };
// Used for code generation failure as well
const cancelCodeGenerationAndReset = () => { const cancelCodeGenerationAndReset = () => {
// When this is the first version, reset the entire app state // When this is the first version, reset the entire app state
if (currentVersion === null) { if (currentVersion === null) {
@ -224,8 +228,11 @@ function App() {
// Reset any existing state // Reset any existing state
reset(); reset();
// Set the input states
setReferenceImages(referenceImages); setReferenceImages(referenceImages);
setInputMode(inputMode); setInputMode(inputMode);
// Kick off the code generation
if (referenceImages.length > 0) { if (referenceImages.length > 0) {
doGenerateCode( doGenerateCode(
{ {
@ -322,6 +329,7 @@ function App() {
} }
function importFromCode(code: string, stack: Stack) { function importFromCode(code: string, stack: Stack) {
// Set input state
setIsImportedFromCode(true); setIsImportedFromCode(true);
// Set up this project // Set up this project
@ -337,6 +345,7 @@ function App() {
]); ]);
setCurrentVersion(0); setCurrentVersion(0);
// Set the app state
setAppState(AppState.CODE_READY); setAppState(AppState.CODE_READY);
} }