@@ -9,6 +9,7 @@ const COMMANDS = {
99 NEW_OR_CONTINUE : 'coderoad.new_or_continue' ,
1010 OPEN_WEBVIEW : 'coderoad.open_webview' ,
1111 SEND_STATE : 'coderoad.send_state' ,
12+ RECEIVE_ACTION : 'coderoad.receive_action' ,
1213 OPEN_FILE : 'coderoad.open_file' ,
1314 RUN_TEST : 'coderoad.test_run' ,
1415}
@@ -22,13 +23,6 @@ interface CreateCommandProps {
2223
2324// React panel webview
2425let webview : any ;
25- let initialTutorial : CR . Tutorial | undefined
26- let initialProgress : CR . Progress = {
27- levels : { } ,
28- stages : { } ,
29- steps : { } ,
30- complete : false ,
31- }
3226
3327export const createCommands = ( { context, machine, storage, git } : CreateCommandProps ) => ( {
3428 // initialize
@@ -37,7 +31,7 @@ export const createCommands = ({ context, machine, storage, git }: CreateCommand
3731 setStorage ( context . workspaceState )
3832
3933 // activate machine
40- webview = new ReactWebView ( context . extensionPath , machine . onReceive )
34+ webview = new ReactWebView ( context . extensionPath )
4135 console . log ( 'webview' , webview . panel . webview . postMessage )
4236 machine . activate ( )
4337 } ,
@@ -50,8 +44,6 @@ export const createCommands = ({ context, machine, storage, git }: CreateCommand
5044 git . gitVersion ( ) ,
5145 git . gitCheckRemoteExists ( ) ,
5246 ] )
53- initialTutorial = tutorial
54- initialProgress = progress
5547 const canContinue = ! ! ( tutorial && progress && hasGit && hasGitRemote )
5648 console . log ( 'canContinue' , canContinue )
5749 // if a tutorial exists, 'CONTINUE'
@@ -85,6 +77,8 @@ export const createCommands = ({ context, machine, storage, git }: CreateCommand
8577 // throw new Error('No valid panel available')
8678 // }
8779 webview . postMessage ( { type : 'SET_STATE' , payload } )
88-
80+ } ,
81+ [ COMMANDS . RECEIVE_ACTION ] : ( action : string | CR . Action ) => {
82+ machine . onReceive ( action )
8983 }
9084} )
0 commit comments