@@ -143,6 +143,7 @@ function store(state, emitter) {
143143 let editor = state . cache ( AceEditor , 'editor' ) . editor
144144 let contents = editor . getValue ( )
145145 let filename = state . selectedFile || 'undefined'
146+ let deviceName = state . selectedDevice === 'serial' ? 'board' : 'disk'
146147
147148 if ( state . selectedDevice === 'serial' ) {
148149 await serial . saveFileContent ( filename , contents )
@@ -153,7 +154,7 @@ function store(state, emitter) {
153154 }
154155
155156 emitter . emit ( 'update-files' )
156- emitter . emit ( 'message' , `${ filename } is saved on ${ state . selectedDevice } .` , 1000 )
157+ emitter . emit ( 'message' , `${ filename } is saved on ${ deviceName } .` , 1000 )
157158 } )
158159 emitter . on ( 'remove' , async ( ) => {
159160 log ( 'remove' )
@@ -318,6 +319,7 @@ function store(state, emitter) {
318319 log ( 'save-filename' , filename )
319320 let oldFilename = state . selectedFile
320321 state . selectedFile = filename
322+ let deviceName = state . selectedDevice === 'serial' ? 'board' : 'disk'
321323
322324 let editor = state . cache ( AceEditor , 'editor' ) . editor
323325 let contents = editor . getValue ( )
@@ -326,7 +328,6 @@ function store(state, emitter) {
326328 // Ask for confirmation to overwrite existing file
327329 let confirmation = true
328330 if ( state . serialFiles . indexOf ( filename ) !== - 1 ) {
329- let deviceName = state . selectedDevice === 'serial' ? 'board' : 'disk'
330331 confirmation = confirm ( `Do you want to overwrite ${ filename } on ${ deviceName } ?` )
331332 }
332333
@@ -343,7 +344,7 @@ function store(state, emitter) {
343344 emitter . emit ( 'update-files' )
344345 emitter . emit ( 'render' )
345346
346- emitter . emit ( 'message' , `${ filename } is saved on ${ state . selectedDevice } .` , 1000 )
347+ emitter . emit ( 'message' , `${ filename } is saved on ${ deviceName } .` , 1000 )
347348 } else {
348349 state . isEditingFilename = false
349350 emitter . emit ( 'render' )
@@ -354,7 +355,6 @@ function store(state, emitter) {
354355 // Ask for confirmation to overwrite existing file
355356 let confirmation = true
356357 if ( state . diskFiles . indexOf ( filename ) !== - 1 ) {
357- let deviceName = state . selectedDevice === 'serial' ? 'board' : 'disk'
358358 confirmation = confirm ( `Do you want to overwrite ${ filename } on ${ deviceName } ?` )
359359 }
360360 if ( confirmation ) {
@@ -370,7 +370,7 @@ function store(state, emitter) {
370370 emitter . emit ( 'update-files' )
371371 emitter . emit ( 'render' )
372372
373- emitter . emit ( 'message' , `${ filename } is saved on ${ state . selectedDevice } .` , 1000 )
373+ emitter . emit ( 'message' , `${ filename } is saved on ${ deviceName } .` , 1000 )
374374 } else {
375375 state . isEditingFilename = false
376376 emitter . emit ( 'render' )
0 commit comments