Skip to content

Commit 9b6be13

Browse files
committed
Reinstall should not reinit
1 parent 01bfd78 commit 9b6be13

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

src/renderer/components

src/renderer/pages/EmulatorsDetailPage.jsx

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,15 @@ function EmulatorsDetailPage() {
194194
});
195195
};
196196

197-
const installEmu = (emulator, code) => {
198-
console.log(emulator);
197+
const reInstallEmu = (emulator, code) => {
199198

200199
setStatePage({
201200
...statePage,
202201
hideInstallButton: true,
203202
});
204203

205204
ipcChannel.sendMessage('emudeck', [
206-
`${code}_install|||${code}_install && ${code}_init`,
205+
`${code}_install|||${code}_install`,
207206
]);
208207

209208
ipcChannel.once(`${code}_install`, (message) => {
@@ -253,6 +252,66 @@ function EmulatorsDetailPage() {
253252
});
254253
});
255254
};
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+
};
256315

257316
const uninstallEmu = (emulator, code, alternative = false) => {
258317
console.log(emulator);
@@ -472,6 +531,7 @@ function EmulatorsDetailPage() {
472531
onChange={selectEmu}
473532
onClick={resetEmu}
474533
onClickInstall={installEmu}
534+
onClickReInstall={reInstallEmu}
475535
onClickUninstall={uninstallEmu}
476536
showNotification={showNotification}
477537
textNotification={textNotification}

0 commit comments

Comments
 (0)