forked from sircharlo/meeting-media-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
67 lines (67 loc) · 1.76 KB
/
main.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
const {
app,
BrowserWindow,
ipcMain
} = require("electron"), {
autoUpdater
} = require("electron-updater"),
os = require("os"),
remote = require("@electron/remote/main");
var win = null;
remote.initialize();
function createUpdateWindow() {
win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
width: 700,
height: 700,
resizable: false,
title: "JW Meeting Media Fetcher"
});
remote.enable(win.webContents);
win.setMenuBarVisibility(false);
win.loadFile("index.html");
}
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
app.on("second-instance", () => {
if (win) {
if (win.isMinimized()) win.restore();
win.focus();
}
});
ipcMain.on("autoUpdate", () => {
autoUpdater.checkForUpdates();
});
autoUpdater.on("error", () => {
win.webContents.send("goAhead");
});
autoUpdater.on("update-not-available", () => {
win.webContents.send("goAhead");
});
autoUpdater.on("update-available", () => {
if (os.platform() == "darwin") {
win.webContents.send("goAhead");
win.webContents.send("macUpdate");
} else {
win.webContents.send("overlay", ["cloud-download-alt", "circle-notch fa-spin text-success"]);
autoUpdater.downloadUpdate();
}
});
autoUpdater.on("update-downloaded", () => {
win.webContents.send("overlay", ["cloud-download-alt", "check-circle"]);
setImmediate(() => {
autoUpdater.quitAndInstall();
});
});
autoUpdater.logger = console;
autoUpdater.autoDownload = false;
app.whenReady().then(createUpdateWindow);
app.on("window-all-closed", () => {
app.exit();
});
}