1- import { extendObservable , observable , toJS } from 'mobx' ;
1+ import { extendObservable , toJS } from 'mobx' ;
22import _ from 'lodash' ;
33const { app} = window . require ( 'electron' ) . remote ;
44
@@ -9,7 +9,7 @@ class MainStore {
99 sqlHistory : [ ] ,
1010 latestResults : undefined ,
1111 queryError : null ,
12- files : observable . map ( ) ,
12+ files : [ ] ,
1313 fileHovering : false
1414 } ) ;
1515
@@ -27,7 +27,8 @@ class MainStore {
2727 const { currentSQL, files} = this . toJS ( ) ;
2828 this . latestResults = null ;
2929 this . queryError = null ;
30- window . worker . alasql ( currentSQL , files , app . getPath ( 'userData' ) )
30+ const fileMap = _ . reduce ( files , ( accum , filePath , i ) => ( { ...accum , [ i + 1 ] : filePath } ) , { } ) ;
31+ window . worker . alasql ( currentSQL , fileMap , app . getPath ( 'userData' ) )
3132 . then ( res => {
3233 this . latestResults = res ;
3334 console . log ( res )
@@ -39,15 +40,13 @@ class MainStore {
3940 }
4041
4142 loadFile ( filePath ) {
42- const fileCount = this . files . size ;
4343 const alreadyLoaded = _ . includes ( this . files . values ( ) , filePath )
4444 if ( alreadyLoaded ) return ;
45- this . files . set ( ` ${ fileCount + 1 } ` , filePath ) ;
45+ this . files . push ( filePath ) ;
4646 }
4747
48- removeFile ( filePathKey ) {
49- const { files} = this . toJS ( ) ;
50- this . files . delete ( filePathKey )
48+ removeFile ( filePathIndex ) {
49+ this . files . splice ( filePathIndex , 1 ) ;
5150 }
5251
5352 toJS ( ) {
0 commit comments