-
-
Notifications
You must be signed in to change notification settings - Fork 310
/
updates.js
83 lines (68 loc) · 2.34 KB
/
updates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const { app, dialog } = require('electron');
const { autoUpdater } = require('electron-updater');
const log = require("electron-log");
const server = 'https://hazel-server-gufzwmrois.now.sh';
const feed = `${server}/update/${process.platform}/${app.getVersion()}`;
const CHECK_UPDATE_INTERVAL = 1000 * 60 * 15; // every 15 mins
const setupAutoUpdates = () => {
// autoUpdater.setFeedURL(feed);
// setInterval(() => {
// autoUpdater.checkForUpdates();
// }, CHECK_UPDATE_INTERVAL);
// autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
// const dialogOpts = {
// type: 'info',
// buttons: ['Restart', 'Later'],
// title: 'Application Update',
// message: process.platform === 'win32' ? releaseNotes : releaseName,
// detail: 'A new version has been downloaded. Restart the application to apply the updates.'
// };
// dialog.showMessageBox(dialogOpts, (response) => {
// if (response === 0) {
// autoUpdater.quitAndInstall();
// }
// });
// });
// autoUpdater.on('error', message => {
// console.error('There was a problem updating the application');
// console.error(message);
// });
log.transports.file.level = 'info';
autoUpdater.logger = log;
autoUpdater.checkForUpdatesAndNotify();
};
// autoUpdater.on('update-not-available', () => {
// dialog.showMessageBox({
// title: 'No Updates',
// message: 'Current version is up-to-date.'
// });
// });
// autoUpdater.on('update-downloaded', () => {
// dialog.showMessageBox({
// title: 'Install Updates',
// message: 'Updates downloaded, application will be quit for update...'
// }, () => {
// setImmediate(() => autoUpdater.quitAndInstall());
// })
// });
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Install Updates',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
};
dialog.showMessageBox(dialogOpts, (response) => {
if (response === 0) {
autoUpdater.quitAndInstall();
}
});
});
const checkForUpdates = (menuItem) => {
autoUpdater.checkForUpdates();
};
module.exports = {
setupAutoUpdates,
checkForUpdates
};