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 6c42c43 commit e00d606
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions main.js
Expand Up @@ -154,14 +154,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 @@ -230,17 +230,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 @@ -261,6 +261,7 @@ try{
ipcMain.handle('writeToLog', (event, data) =>
fs.writeFileSync(logFile, `[${new Date().toLocaleString()}] ${data}\n`));
}catch(error){
console.log(error);
fs.writeFileSync(logFile, `[${new Date().toLocaleString()}] ${JSON.stringify(error)}\n`);
}

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e00d606

Please sign in to comment.