@@ -79,7 +79,6 @@ const LeftContainer = (): JSX.Element => {
79
79
primBtnAction : null ,
80
80
primBtnLabel : null ,
81
81
secBtnAction : ( ) => {
82
- // TODO: Create reducer to delete components from state
83
82
closeModal ( ) ;
84
83
}
85
84
} )
@@ -95,17 +94,6 @@ const LeftContainer = (): JSX.Element => {
95
94
key = { i }
96
95
button
97
96
onClick = { ( ) => chooseGenOptions ( i ) }
98
- // onClick={() =>
99
- // createApplication({
100
- // // path,
101
- // // trying this with an absolute path because the electron dialogue box isn't working
102
- // path: '/Users/tylersullberg/',
103
- // components,
104
- // genOption,
105
- // appName: 'reactype_app',
106
- // exportAppBool: null
107
- // })
108
- // }
109
97
style = { {
110
98
border : '1px solid #3f51b5' ,
111
99
marginBottom : '2%' ,
@@ -117,38 +105,32 @@ const LeftContainer = (): JSX.Element => {
117
105
) ) }
118
106
</ List >
119
107
) ;
120
- // const chooseAppDir = () => {
121
- // console.log('CALLED CHOOSE APP DIR: ', genOption);
122
- // window.api.chooseAppDir();
123
- // };
124
-
108
+
125
109
// helper function called by showGenerateAppModal
126
110
// this function will prompt the user to choose an app directory once they've chosen their export option
127
111
const chooseGenOptions = ( genOpt : number ) => {
128
112
// set export option: 0 --> export only components, 1 --> export full project
129
-
130
- // setGenOption(genOpt);
131
113
genOption = genOpt ;
132
- console . log ( 'CALLED CHOOSE GEN OPTION: ' , genOption ) ;
133
- // closeModal
134
- // exportProject('/Users', 'NEW PROJECT', genOpt, state.components, state.rootComponents);
135
- // closeModal();
136
- // Choose app dir
137
- // window.api.chooseAppDir;
138
-
139
114
window . api . chooseAppDir ( ) ;
140
-
141
- // closeModal
142
-
143
115
closeModal ( ) ;
144
116
} ;
145
117
118
+ // removes all listeners for the app_dir_selected event
119
+ // this is important because otherwise listeners will pile up and events will trigger multiple events
120
+ window . api . removeAllAppDirChosenListeners ( ) ;
121
+
146
122
// add listener for when an app directory is chosen
147
123
// when a directory is chosen, the callback will export the project to the chosen folder
148
124
// Note: this listener is imported from the main process via preload.js
149
- window . api . appDirChosen ( path => {
125
+ window . api . addAppDirChosenListener ( path => {
150
126
console . log ( 'CALLED APPDIRCHOSEN: ' , genOption ) ;
151
- exportProject ( path , 'NEW PROJECT' , genOption , state . components , state . rootComponents ) ;
127
+ exportProject (
128
+ path ,
129
+ 'NEW PROJECT' ,
130
+ genOption ,
131
+ state . components ,
132
+ state . rootComponents
133
+ ) ;
152
134
} ) ;
153
135
154
136
setModal (
0 commit comments