Closed benloh closed 1 year ago
requested review from @jdanish
@jdanish This isn't a super critical fix, but it was definitely odd behavior if you're editing in the code view all the time. Not super urgent for merging.
In GitLab by @jdanish on Oct 2, 2022, 05:43
I actually couldn't reproduce the error prior to pulling this. However, after getting it all seems fine with the various ways of saving code doing as expected.
mentioned in commit f619a9dd06cc8f210ad9bd4208e7e217818ea233
Merges dev-bl/fix-code-submit -> dev-next
The Problem
Upon sending a code update from the ScriptEditor's Code view, the ScriptEditor would not remain in Code view but instead would act as if the blueprint had been unselected and go back to the blueprint selection view.
Analysis
The problem stems from the use of the
NET:SCRIPT_UPDATE
call byac-wizcore.ts
. There were three handlers forNET:SCRIPT_UPDATE
:project-server
,Main
, andScriptEditor
. Becauseac-wizcore
was making aUR.CallMessage
, all three handlers would return a value. But onlyproject-server
was returning the correct value.Main
andScriptEditor
were using the message simply to log a message that the script had been changed and not explicitly returning anything. The result is the returned value looked something like this:{ { bpName: 'Algae'}, {} }
. This was then passed on toSELECT_SCRIPT
raised message, and since the data is now munged, SELECT_SCRIPT would make ScriptEditor think no blueprint was selected.Solution
The fix was to split out the
NET:SCRIPT_UPDATE
call into the main data call, and a secondaryNET:SCRIPT_UPDATED
call thatMain
andScriptEditor
could handle separately. This makes sure theCallMessage
doesn't end up with munged return values.To Test
If the ScripteEditor instead goes back to the script selection view, then this fix did not work.