@@ -22,6 +22,7 @@ export type DependencyBlock = {
2222
2323interface EditContextProps {
2424 scriptPath : string ;
25+ initialScriptId : string ;
2526 children : React . ReactNode ;
2627}
2728
@@ -62,14 +63,15 @@ interface EditContextState {
6263const EditContext = createContext < EditContextState > ( { } as EditContextState ) ;
6364const EditContextProvider : React . FC < EditContextProps > = ( {
6465 scriptPath,
66+ initialScriptId,
6567 children,
6668} ) => {
6769 const [ loading , setLoading ] = useState ( true ) ;
6870 const [ notFound , setNotFound ] = useState ( false ) ;
6971 const [ root , setRoot ] = useState < Tool > ( { } as Tool ) ;
7072 const [ tools , setTools ] = useState < Tool [ ] > ( [ ] ) ;
7173 const [ script , setScript ] = useState < Block [ ] > ( [ ] ) ;
72- const [ scriptId , setScriptId ] = useState < number > ( - 1 ) ;
74+ const [ scriptId , setScriptId ] = useState < number > ( parseInt ( initialScriptId ) ) ;
7375 const [ visibility , setVisibility ] = useState <
7476 'public' | 'private' | 'protected'
7577 > ( 'private' ) ;
@@ -90,7 +92,7 @@ const EditContextProvider: React.FC<EditContextProps> = ({
9092 setModels ( m ) ;
9193 } ) ;
9294
93- getScript ( scriptPath )
95+ getScript ( initialScriptId )
9496 . then ( async ( script ) => {
9597 if ( script === undefined ) {
9698 setNotFound ( true ) ;
0 commit comments