Skip to content

Commit

Permalink
fix(electron): proper autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
thesophiaxu committed Apr 14, 2022
1 parent 51d22e8 commit cd7deb3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/unigraph-dev-electron/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ if (!gotTheLock) {
process.exit(0);
}

if (!isDev()) autoUpdater.checkForUpdatesAndNotify();
log.transports.file.level = 'debug';
autoUpdater.logger = log;

function isUnigraphPortOpen(port) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -215,7 +216,21 @@ function unigraphLoaded() {

let isAppClosing = false;

autoUpdater.on('update-downloaded', async (info) => {
const choice = await require('electron').dialog.showMessageBox({
type: 'question',
buttons: ['OK', 'Quit and update'],
title: 'New update downloaded',
message: `New update has been downloaded (version ${info.version}), and will be automatically installed after quit.`,
});
if (choice.response === 1) {
isAppClosing = true;
autoUpdater.quitAndInstall();
}
});

app.whenReady().then(() => {
if (!isDev()) autoUpdater.checkForUpdates();
tray = new Tray(nativeImage.createFromDataURL(unigraph_trayIcon));
tray.setToolTip('Unigraph');
trayMenu = createTrayMenu((newTemplate) => {
Expand Down

0 comments on commit cd7deb3

Please sign in to comment.