auto updates

This commit is contained in:
Andrew Gundersen 2021-04-12 12:18:37 -05:00
commit 4b6d42612a
6 changed files with 100 additions and 26 deletions

View file

@ -5,7 +5,7 @@
"use strict";
import { protocol } from "electron";
import { protocol, autoUpdater, dialog } from "electron";
import { initApp } from './background/init';
// Scheme must be registered before the app is ready
@ -23,3 +23,24 @@ const isDev = require('electron-is-dev');
initApp(isDev);
})();
// Auto app updates.
if (!isDev) {
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
setInterval(() => {
autoUpdater.checkForUpdates()
}, 5000)
}