@@ -194,16 +194,15 @@ function EmulatorsDetailPage() {
194
194
} ) ;
195
195
} ;
196
196
197
- const installEmu = ( emulator , code ) => {
198
- console . log ( emulator ) ;
197
+ const reInstallEmu = ( emulator , code ) => {
199
198
200
199
setStatePage ( {
201
200
...statePage ,
202
201
hideInstallButton : true ,
203
202
} ) ;
204
203
205
204
ipcChannel . sendMessage ( 'emudeck' , [
206
- `${ code } _install|||${ code } _install && ${ code } _init ` ,
205
+ `${ code } _install|||${ code } _install` ,
207
206
] ) ;
208
207
209
208
ipcChannel . once ( `${ code } _install` , ( message ) => {
@@ -253,6 +252,66 @@ function EmulatorsDetailPage() {
253
252
} ) ;
254
253
} ) ;
255
254
} ;
255
+
256
+ const installEmu = ( emulator , code ) => {
257
+ console . log ( emulator ) ;
258
+
259
+ setStatePage ( {
260
+ ...statePage ,
261
+ hideInstallButton : true ,
262
+ } ) ;
263
+
264
+ ipcChannel . sendMessage ( 'emudeck' , [
265
+ `${ code } _install|||${ code } _install && ${ code } _init` ,
266
+ ] ) ;
267
+
268
+ ipcChannel . once ( `${ code } _install` , ( message ) => {
269
+ // console.log({ status });
270
+ let status = message . stdout ;
271
+ status . replace ( '\n' , '' ) ;
272
+ // Lets check if it did install
273
+ ipcChannel . sendMessage ( 'emudeck' , [
274
+ `${ code } _IsInstalled|||${ code } _IsInstalled` ,
275
+ ] ) ;
276
+
277
+ ipcChannel . once ( `${ code } _IsInstalled` , ( message ) => {
278
+ // console.log({ status });
279
+ status = message . stdout ;
280
+ status . replace ( '\n' , '' ) ;
281
+
282
+ if ( status . includes ( 'true' ) ) {
283
+ setStatePage ( {
284
+ ...statePage ,
285
+ textNotification : `${ code } installed! 🎉` ,
286
+ showNotification : true ,
287
+ hideInstallButton : false ,
288
+ } ) ;
289
+ // We set the emu as install = yes
290
+ setState ( {
291
+ ...state ,
292
+ installEmus : {
293
+ ...installEmus ,
294
+ [ emulator ] : {
295
+ id : emulator ,
296
+ name : code ,
297
+ status : true ,
298
+ } ,
299
+ } ,
300
+ } ) ;
301
+ } else {
302
+ setStatePage ( {
303
+ ...statePage ,
304
+ textNotification : `There was an issue trying to install ${ code } 😥` ,
305
+ showNotification : true ,
306
+ hideInstallButton : false ,
307
+ } ) ;
308
+ // We save it on localstorage
309
+ let json = JSON . stringify ( state ) ;
310
+ localStorage . setItem ( 'settings_emudeck' , json ) ;
311
+ }
312
+ } ) ;
313
+ } ) ;
314
+ } ;
256
315
257
316
const uninstallEmu = ( emulator , code , alternative = false ) => {
258
317
console . log ( emulator ) ;
@@ -472,6 +531,7 @@ function EmulatorsDetailPage() {
472
531
onChange = { selectEmu }
473
532
onClick = { resetEmu }
474
533
onClickInstall = { installEmu }
534
+ onClickReInstall = { reInstallEmu }
475
535
onClickUninstall = { uninstallEmu }
476
536
showNotification = { showNotification }
477
537
textNotification = { textNotification }
0 commit comments