|
1 | | -const { dialog, ipcMain } = require('electron'); |
| 1 | +const { ipcMain } = require('electron'); |
2 | 2 | const { menubar } = require('menubar'); |
| 3 | +const { autoUpdater } = require("electron-updater") |
3 | 4 | const path = require('path'); |
4 | 5 | const AutoLaunch = require('auto-launch'); |
5 | | -const GhReleases = require('electron-gh-releases'); |
6 | 6 |
|
7 | 7 | const iconIdle = path.join(__dirname, 'assets', 'images', 'tray-idleTemplate.png'); |
8 | 8 | const iconActive = path.join(__dirname, 'assets', 'images', 'tray-active.png'); |
9 | 9 |
|
10 | | -const isDarwin = process.platform === 'darwin'; |
11 | | -const isLinux = process.platform === 'linux'; |
12 | | -const isWindows = process.platform === 'win32'; |
13 | | - |
14 | 10 | const autoStart = new AutoLaunch({ |
15 | 11 | name: 'Gitify', |
16 | 12 | path: process.execPath.match(/.*?\.app/)[0], |
@@ -39,7 +35,7 @@ const menubarApp = menubar({ |
39 | 35 | menubarApp.on('ready', () => { |
40 | 36 | menubarApp.tray.setIgnoreDoubleClickEvents(true); |
41 | 37 |
|
42 | | - checkAutoUpdate(); |
| 38 | + autoUpdater.checkForUpdatesAndNotify(); |
43 | 39 |
|
44 | 40 | ipcMain.on('reopen-window', () => menubarApp.showWindow()); |
45 | 41 | ipcMain.on('startup-enable', () => autoStart.enable()); |
@@ -70,54 +66,4 @@ menubarApp.on('ready', () => { |
70 | 66 | menubarApp.positioner.move('trayCenter', trayBounds); |
71 | 67 | menubarApp.window.resizable = false; |
72 | 68 | }); |
73 | | - |
74 | | - function checkAutoUpdate() { |
75 | | - if (isWindows || isLinux) { |
76 | | - return; |
77 | | - } |
78 | | - |
79 | | - let autoUpdateOptions = { |
80 | | - repo: 'manosim/gitify', |
81 | | - currentVersion: menubarApp.app.getVersion(), |
82 | | - }; |
83 | | - |
84 | | - const updater = new GhReleases(autoUpdateOptions); |
85 | | - |
86 | | - updater.on('error', (event, message) => { |
87 | | - console.log('ERRORED.'); |
88 | | - console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); |
89 | | - }); |
90 | | - |
91 | | - updater.on('update-downloaded', () => { |
92 | | - // Restart the app(ask) and install the update |
93 | | - confirmAutoUpdate(updater); |
94 | | - }); |
95 | | - |
96 | | - // Check for updates |
97 | | - updater.check((err, status) => { |
98 | | - if (!err && status) { |
99 | | - updater.download(); |
100 | | - } |
101 | | - }); |
102 | | - } |
103 | | - |
104 | | - function confirmAutoUpdate(updater) { |
105 | | - dialog.showMessageBox( |
106 | | - { |
107 | | - type: 'question', |
108 | | - buttons: ['Update & Restart', 'Cancel'], |
109 | | - title: 'Update Available', |
110 | | - cancelId: 99, |
111 | | - message: |
112 | | - 'There is an update available. Would you like to update Gitify now?', |
113 | | - }, |
114 | | - response => { |
115 | | - console.log('Exit: ' + response); |
116 | | - menubarApp.app.dock.hide(); |
117 | | - if (response === 0) { |
118 | | - updater.install(); |
119 | | - } |
120 | | - } |
121 | | - ); |
122 | | - } |
123 | 69 | }); |
0 commit comments