File tree Expand file tree Collapse file tree 6 files changed +22
-7
lines changed Expand file tree Collapse file tree 6 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,11 @@ class Channel implements Channel {
297297 vscode . commands . executeCommand ( COMMANDS . RUN_TEST )
298298 return
299299
300+ case 'EDITOR_SYNC_PROGRESS' :
301+ // update progress when a level is deemed complete in the client
302+ await this . context . progress . syncProgress ( action . payload . progress )
303+ return
304+
300305 default :
301306 logger ( `No match for action type: ${ actionType } ` )
302307 return
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ class Progress {
3939 public reset = ( ) => {
4040 this . set ( defaultValue )
4141 }
42+ public syncProgress = ( progress : T . Progress ) : T . Progress => {
43+ const next = { ...this . value , ...progress }
44+ return this . set ( next )
45+ }
4246 public setStepComplete = ( tutorial : TT . Tutorial , stepId : string ) : T . Progress => {
4347 const next = this . value
4448 // mark step complete
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { Menu } from '@alifd/next'
55import * as selectors from '../../services/selectors'
66import Icon from '../../components/Icon'
77import Level from './components/Level'
8- import logger from 'services/logger'
8+ import logger from '../../ services/logger'
99
1010interface PageProps {
1111 context : T . MachineContext
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ for (const required of requiredKeys) {
99export const DEBUG : boolean = ( process . env . REACT_APP_DEBUG || '' ) . toLowerCase ( ) === 'true'
1010export const VERSION : string = process . env . VERSION || 'unknown'
1111export const NODE_ENV : string = process . env . NODE_ENV || 'development'
12- export const LOG : boolean =
13- ( process . env . REACT_APP_LOG || '' ) . toLowerCase ( ) === 'true' && process . env . NODE_ENV !== 'production'
12+ export const LOG : boolean = ( process . env . REACT_APP_LOG || '' ) . toLowerCase ( ) === 'true'
1413export const TUTORIAL_LIST_URL : string = process . env . REACT_APP_TUTORIAL_LIST_URL || ''
1514export const SENTRY_DSN : string | null = process . env . REACT_APP_SENTRY_DSN || null
Original file line number Diff line number Diff line change @@ -74,6 +74,14 @@ export default (editorSend: any) => ({
7474 } )
7575 }
7676 } ,
77+ syncLevelProgress ( context : CR . MachineContext ) : void {
78+ editorSend ( {
79+ type : 'EDITOR_SYNC_PROGRESS' ,
80+ payload : {
81+ progress : context . progress ,
82+ } ,
83+ } )
84+ } ,
7785 clearStorage ( ) : void {
7886 editorSend ( { type : 'TUTORIAL_CLEAR' } )
7987 } ,
Original file line number Diff line number Diff line change @@ -207,13 +207,12 @@ export const createMachine = (options: any) => {
207207 target : 'Normal' ,
208208 actions : [ 'loadStep' ] ,
209209 } ,
210- LEVEL_COMPLETE : {
211- target : 'LevelComplete' ,
212- actions : [ 'updateLevelProgress' ] ,
213- } ,
210+ LEVEL_COMPLETE : 'LevelComplete' ,
214211 } ,
215212 } ,
216213 LevelComplete : {
214+ onEntry : [ 'updateLevelProgress' ] ,
215+ onExit : [ 'syncLevelProgress' ] ,
217216 on : {
218217 LEVEL_NEXT : {
219218 target : '#tutorial-load-next' ,
You can’t perform that action at this time.
0 commit comments