File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change 77function installFromFiles ( ) {
88 return new Promise ( resolve => {
99
10- // Collect all files
11- const fileCollection = {
12- files : [ ]
13- } ;
14-
1510 // Request multi-file selection from user
1611 Espruino . Core . Utils . fileOpenDialog ( {
17- id :"installappfiles" ,
18- type :"arraybuffer" ,
19- multi :true ,
20- mimeType :"*/*" ,
21- onCancel : function ( ) {
12+ id :"installappfiles" ,
13+ type :"arraybuffer" ,
14+ multi :true ,
15+ mimeType :"*/*" ,
16+ onComplete : function ( files ) {
17+ try {
18+ if ( ! files ) return resolve ( ) ; // user cancelled
19+ const mapped = files . map ( function ( f ) {
20+ return { name : f . fileName , data : f . contents } ;
21+ } ) ;
22+ processFiles ( mapped , resolve ) ;
23+ } catch ( err ) {
24+ showToast ( 'Install failed: ' + err , 'error' ) ;
25+ console . error ( err ) ;
2226 resolve ( ) ;
23- } ,
24- onComplete : function ( ) {
25- processFiles ( fileCollection . files , resolve ) ;
26- } } , function ( fileData , mimeType , fileName ) {
27-
28- // Collect each file as callback is invoked
29- fileCollection . files . push ( {
30- name : fileName ,
31- data : fileData
32- } ) ;
27+ }
28+ }
3329 } ) ;
3430 } ) ;
3531}
You can’t perform that action at this time.
0 commit comments