File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ const newFileContent = `# This program was created in Arduino Lab for MicroPytho
99
1010print('Hello, MicroPython!')
1111`
12+ async function sleep ( ms ) {
13+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
14+ }
1215
1316async function confirmDialog ( msg , cancelMsg , confirmMsg ) {
1417 // cancelMsg = cancelMsg || 'Cancel'
@@ -103,15 +106,16 @@ async function store(state, emitter) {
103106 emitter . emit ( 'render' )
104107 } )
105108
106- emitter . on ( 'change-view' , ( view ) => {
107- if ( state . view === 'file-manager' ) {
108- if ( view != state . view ) {
109- state . selectedFiles = [ ]
110- }
111- emitter . emit ( 'refresh-files' )
109+ emitter . on ( 'change-view' , async ( view ) => {
110+ if ( state . view === view ) {
111+ return
112+ } else {
113+ state . selectedFiles = [ ]
112114 }
113115 if ( view === 'file-manager' ) {
114116 emitter . emit ( 'stop' )
117+ await sleep ( 250 ) // Give the board time to stop the program and return to the prompt
118+ emitter . emit ( 'refresh-files' )
115119 }
116120 state . view = view
117121 emitter . emit ( 'render' )
You can’t perform that action at this time.
0 commit comments