Update moved useEffect hook after merge

This commit is contained in:
Frank Noirot
2023-09-13 14:52:43 -04:00
parent bcb05d02b4
commit 7aaf923529

View File

@ -98,7 +98,18 @@ export function useEngineWithStream(streamRef: React.RefObject<HTMLElement>) {
const asyncWrap = async () => { const asyncWrap = async () => {
try { try {
if (!defferedCode) { if (!defferedCode) {
setAst(null) setAst({
start: 0,
end: 0,
body: [],
nonCodeMeta: {
noneCodeNodes: {},
start: null,
},
})
setProgramMemory({ root: {}, return: null })
engineCommandManager.endSession()
engineCommandManager.startNewSession()
return return
} }
const _ast = await asyncParser(defferedCode) const _ast = await asyncParser(defferedCode)
@ -113,26 +124,27 @@ export function useEngineWithStream(streamRef: React.RefObject<HTMLElement>) {
{ {
root: { root: {
_0: { _0: {
type: 'userVal', type: 'UserVal',
value: 0, value: 0,
__meta: [], __meta: [],
}, },
_90: { _90: {
type: 'userVal', type: 'UserVal',
value: 90, value: 90,
__meta: [], __meta: [],
}, },
_180: { _180: {
type: 'userVal', type: 'UserVal',
value: 180, value: 180,
__meta: [], __meta: [],
}, },
_270: { _270: {
type: 'userVal', type: 'UserVal',
value: 270, value: 270,
__meta: [], __meta: [],
}, },
}, },
return: null,
}, },
engineCommandManager engineCommandManager
) )
@ -140,6 +152,9 @@ export function useEngineWithStream(streamRef: React.RefObject<HTMLElement>) {
const { artifactMap, sourceRangeMap } = const { artifactMap, sourceRangeMap } =
await engineCommandManager.waitForAllCommands() await engineCommandManager.waitForAllCommands()
setIsExecuting(false) setIsExecuting(false)
if (programMemory !== undefined) {
setProgramMemory(programMemory)
}
setArtifactMap({ artifactMap, sourceRangeMap }) setArtifactMap({ artifactMap, sourceRangeMap })
const unSubHover = engineCommandManager.subscribeToUnreliable({ const unSubHover = engineCommandManager.subscribeToUnreliable({
@ -168,9 +183,6 @@ export function useEngineWithStream(streamRef: React.RefObject<HTMLElement>) {
}, },
}) })
unsubFn.push(unSubHover, unSubClick) unsubFn.push(unSubHover, unSubClick)
if (programMemory !== undefined) {
setProgramMemory(programMemory)
}
setError() setError()
} catch (e: any) { } catch (e: any) {