2022-01-28 20:06:36 +00:00
|
|
|
const { app, autoUpdater } = require('electron');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-02-08 13:07:28 +00:00
|
|
|
const { get } = require('request');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
|
|
|
|
2022-04-12 16:32:27 +00:00
|
|
|
module.exports = process.platform === 'linux' ? new (class HostLinux extends require('events').EventEmitter {
|
2021-12-09 16:25:14 +00:00
|
|
|
setFeedURL(url) {
|
2022-04-12 16:32:27 +00:00
|
|
|
this.url = url;
|
2021-12-09 16:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
quitAndInstall() {
|
2022-01-28 20:06:36 +00:00
|
|
|
app.relaunch();
|
|
|
|
app.quit();
|
2021-12-09 16:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async checkForUpdates() {
|
2022-04-12 16:32:27 +00:00
|
|
|
get(this.url, (e, r) => {
|
|
|
|
if (e) return this.emit('error');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-04-12 16:32:27 +00:00
|
|
|
if (r.statusCode === 204) return this.emit('update-not-available');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-04-12 16:32:27 +00:00
|
|
|
this.emit('update-manually');
|
|
|
|
});
|
2021-12-09 16:25:14 +00:00
|
|
|
}
|
2022-04-12 16:32:27 +00:00
|
|
|
})() : autoUpdater;
|