File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ class Channel implements Channel {
7272 this . context . setTutorial ( this . workspaceState , tutorialData )
7373 tutorialConfig ( tutorialData )
7474 return
75+ case 'EDITOR_SYNC_PROGRESS' :
76+ // sync client progress on server
77+ this . context . position . set ( action . payload . position )
78+ this . context . progress . set ( action . payload . progress )
79+ return
7580 // run unit tests on step
7681 case 'TEST_RUN' :
7782 vscode . commands . executeCommand ( 'coderoad.run_test' , action . payload )
@@ -97,7 +102,12 @@ class Channel implements Channel {
97102 switch ( action . type ) {
98103 case 'TEST_PASS' :
99104 // update local storage stepProgress
100- this . context . progress . setStepComplete ( action . payload . stepId )
105+ const progress = this . context . progress . setStepComplete ( action . payload . stepId )
106+ const tutorial = this . context . tutorial . get ( )
107+ if ( ! tutorial ) {
108+ throw new Error ( 'Error with current tutorial' )
109+ }
110+ this . context . position . setPositionFromProgress ( tutorial , progress )
101111 saveCommit ( )
102112 }
103113
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ interface Props {
1515}
1616
1717const ErrorView = ( { error } : Props ) => {
18- console . log ( error )
18+ console . log ( error )
1919 return (
2020 < div style = { styles . container } >
2121 < h1 > Error</ h1 >
Original file line number Diff line number Diff line change @@ -11,6 +11,15 @@ export default {
1111 type : 'EDITOR_TUTORIAL_LOAD' ,
1212 } )
1313 } ,
14+ syncProgress ( context : CR . MachineContext ) {
15+ // sync progress in editor local storage for persistence
16+ channel . editorSend ( {
17+ type : 'EDITOR_SYNC_PROGRESS' ,
18+ payload : {
19+ progress : context . progress ,
20+ }
21+ } )
22+ } ,
1423 initializeTutorial ( context : CR . MachineContext , event : CR . MachineEvent ) {
1524 // setup test runner and git
1625 const { tutorial} = event . data . payload
You can’t perform that action at this time.
0 commit comments