Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Switch to async dialog boxes to work around electron/electron#31152
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendaryLinux committed Oct 31, 2021
1 parent 2d4e8ad commit ca8eebe
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions main.js
Expand Up @@ -156,14 +156,14 @@ app.whenReady().then(async () => {
!fs.existsSync(config.baseRomPath) || // Base ROM no longer exists
md5(fs.readFileSync(config.baseRomPath)) !== baseRomHash // The base ROM hash is wrong (user chose the wrong file)
) {
let baseRomPath = dialog.showOpenDialogSync(null, {
let baseRomPath = await dialog.showOpenDialog(null, {
title: 'Select base ROM',
buttonLabel: 'Choose ROM',
message: 'Choose a base ROM to be used when patching.',
});
// Save base rom filepath back to config file
if (baseRomPath) {
config.baseRomPath = baseRomPath[0];
if (!baseRomPath.canceled && baseRomPath.filePaths.length > 0) {
config.baseRomPath = baseRomPath.filePaths[0];
fs.writeFileSync(configPath, JSON.stringify(Object.assign({}, config, {
baseRomPath: config.baseRomPath,
})));
Expand Down Expand Up @@ -232,17 +232,17 @@ launchSNI();
ipcMain.on('requestSharedData', (event, args) => {
event.sender.send('sharedData', sharedData);
});
ipcMain.on('setLauncher', (event, args) => {
ipcMain.on('setLauncher', async (event, args) => {
// Allow the user to specify a program to launch the ROM
const config = JSON.parse(fs.readFileSync(configPath).toString());
const launcherPath = dialog.showOpenDialogSync({
const launcherPath = await dialog.showOpenDialog({
title: 'Locate ROM Launcher',
buttonLabel: 'Select Launcher',
message: 'Choose an executable to be used when launching the ROM',
});
if (launcherPath) {
if (!launcherPath.canceled && launcherPath.filePaths.length > 0) {
fs.writeFileSync(configPath, JSON.stringify(Object.assign({}, config, {
launcherPath: launcherPath[0],
launcherPath: launcherPath.filePaths[0],
})));
}
});
Expand All @@ -263,5 +263,6 @@ try{
ipcMain.handle('writeToLog', (event, data) =>
fs.writeSync(logFile, `[${new Date().toLocaleString()}] ${data}\n`));
}catch(error){
console.log(error);
fs.writeSync(logFile, `[${new Date().toLocaleString()}] ${JSON.stringify(error)}`);
}

0 comments on commit ca8eebe

Please sign in to comment.