Skip to content

Commit

Permalink
chore: Update electron main.js to check for updates and improve insta…
Browse files Browse the repository at this point in the history
…llation checking
  • Loading branch information
truemiller committed May 13, 2024
1 parent e0b8f41 commit 8308235
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ async function launchNextAppDev() {
}

ipcMain.on('check', async function (event, argument) {
// Update
try {
event.sender.send('response', 'Checking for updates');
await macUpdater.checkForUpdates();
} catch (e) {
console.error(e);
event.sender.send('response', e);
}

// Setup
try {
event.sender.send('response', 'Checking installation');
if (!isDev) {
Expand Down Expand Up @@ -413,28 +423,7 @@ app.on('ready', async () => {
if (platform === 'darwin') {
app.dock?.setIcon(path.join(__dirname, 'assets/icons/tray-logged-out.png'));
}

const downloadNotification = new Notification({
title: 'Downloading Update',
body: 'Downloading update in the background',
});

const updateResult = await macUpdater
.checkForUpdates()
.then((result) => {
if (result) {
downloadNotification.show();
// downloadNotification.on('close', () => {
// createSplashWindow();
// });
console.log(result);
console.log(result);
console.log(result);
} else {
createSplashWindow();
}
})
.catch((e) => console.log(e));
createSplashWindow();
});

app.on('window-all-closed', () => {
Expand All @@ -448,7 +437,6 @@ app.on('before-quit', () => {
});

// PROCESS SPECIFIC EVENTS (HANDLES NON-GRACEFUL TERMINATION)

process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
// Clean up your child processes here
Expand Down

0 comments on commit 8308235

Please sign in to comment.