Skip to content

Commit 5603580

Browse files
authored
Merge pull request #43 from h15200/updater
Updater
2 parents 09e73ad + 80cbe55 commit 5603580

File tree

4 files changed

+45
-67
lines changed

4 files changed

+45
-67
lines changed

main.js

Lines changed: 35 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ require("./main_httpController.js")();
5555
require("./main_grpcController.js")();
5656

5757
// configure logging
58-
// autoUpdater.logger = log;
59-
// autoUpdater.logger.transports.file.level = "info";
60-
// log.info("App starting...");
58+
autoUpdater.logger = log;
59+
autoUpdater.logger.transports.file.level = "info";
60+
log.info("App starting...");
6161

6262
let mainWindow;
6363

@@ -170,26 +170,6 @@ isDev
170170
================================
171171
`);
172172

173-
// let isDev = false;
174-
// console.log("process.defaultApp ->", process.defaultApp);
175-
// console.log("process.execPath -> ", process.execPath);
176-
177-
// if (
178-
// process.defaultApp ||
179-
// /[\\/]electron-prebuilt[\\/]/.test(process.execPath) ||
180-
// /[\\/]electron[\\/]/.test(process.execPath)
181-
// ) {
182-
// isDev = true;
183-
// }
184-
// console.log(
185-
// "current regex test -> ",
186-
// /[\\/]electron-prebuilt[\\/]/.test(process.execPath)
187-
// );
188-
// if (isDev) console.log("isDev is TRUE");
189-
// if (isDev === false) console.log("isDev is FALSE");
190-
// Temporary fix broken high-dpi scale factor on Windows (125% scaling)
191-
// info: https://github.com/electron/electron/issues/9691
192-
193173
if (process.platform === "win32") {
194174
// if user is on windows...
195175
app.commandLine.appendSwitch("high-dpi-support", "true");
@@ -278,8 +258,6 @@ function createWindow() {
278258
// tldr: Remove the BrowserWindow instance that we created earlier by setting its value to null when we exit Swell
279259
mainWindow = null;
280260
});
281-
282-
// moved require mainmenu to top
283261
}
284262

285263
/********* end of createWindow declaration ******/
@@ -327,38 +305,38 @@ const sendStatusToWindow = (text) => {
327305
}
328306
};
329307

330-
// ipcMain.on("check-for-update", () => {
331-
// //listens to ipcRenderer in UpdatePopUpContainer.jsx
332-
// if (!isDev) autoUpdater.checkForUpdates();
333-
// });
334-
// autoUpdater.on('checking-for-update', () => {
335-
// sendStatusToWindow('Checking for update...');
336-
// // });
337-
// autoUpdater.on('update-available', info => {
338-
// sendStatusToWindow('Update available.');
339-
// });
340-
// autoUpdater.on('update-not-available', info => {
341-
// sendStatusToWindow('Update not available.');
342-
// });
343-
// autoUpdater.on("error", (err) => {
344-
// console.error("autoUpdater error -> ", err);
345-
// sendStatusToWindow(`Error in auto-updater`);
346-
// });
347-
// autoUpdater.on("download-progress", (progressObj) => {
348-
// sendStatusToWindow(
349-
// `Download speed: ${progressObj.bytesPerSecond} - Downloaded ${progressObj.percent}% (${progressObj.transferred} + '/' + ${progressObj.total} + )`
350-
// );
351-
// });
352-
// autoUpdater.on("update-downloaded", (info) => {
353-
// sendStatusToWindow("Update downloaded.");
354-
// });
355-
356-
// autoUpdater.on('update-downloaded', info => {
357-
// // Wait 5 seconds, then quit and install
358-
// // In your application, you don't need to wait 500 ms.
359-
// // You could call autoUpdater.quitAndInstall(); immediately
360-
// autoUpdater.quitAndInstall();
361-
// });
308+
ipcMain.on("check-for-update", () => {
309+
//listens to ipcRenderer in UpdatePopUpContainer.jsx
310+
if (!isDev) autoUpdater.checkForUpdates();
311+
});
312+
autoUpdater.on("checking-for-update", () => {
313+
sendStatusToWindow("Checking for update...");
314+
});
315+
autoUpdater.on("update-available", (info) => {
316+
sendStatusToWindow("Update available.");
317+
});
318+
autoUpdater.on("update-not-available", (info) => {
319+
sendStatusToWindow("Update not available.");
320+
});
321+
autoUpdater.on("error", (err) => {
322+
console.error("autoUpdater error -> ", err);
323+
sendStatusToWindow(`Error in auto-updater`);
324+
});
325+
autoUpdater.on("download-progress", (progressObj) => {
326+
sendStatusToWindow(
327+
`Download speed: ${progressObj.bytesPerSecond} - Downloaded ${progressObj.percent}% (${progressObj.transferred} + '/' + ${progressObj.total} + )`
328+
);
329+
});
330+
autoUpdater.on("update-downloaded", (info) => {
331+
sendStatusToWindow("Update downloaded.");
332+
});
333+
334+
autoUpdater.on("update-downloaded", (info) => {
335+
// Wait 5 seconds, then quit and install
336+
// In your application, you don't need to wait 500 ms.
337+
// You could call autoUpdater.quitAndInstall(); immediately
338+
autoUpdater.quitAndInstall();
339+
});
362340
ipcMain.on("quit-and-install", () => {
363341
autoUpdater.quitAndInstall();
364342
});

preload.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ contextBridge.exposeInMainWorld("api", {
55
// allowlist channels
66
const allowedChannels = [
77
"toMain",
8+
"check-for-update",
89
"confirm-clear-history",
10+
"export-collection",
11+
"fatalError",
12+
"import-collection",
913
"import-proto",
10-
"quit-and-install",
11-
"protoParserFunc-request",
1214
"open-http",
1315
"open-gql",
14-
"import-collection",
15-
"export-collection",
16-
"open-http",
1716
"open-grpc",
17+
"protoParserFunc-request",
18+
"quit-and-install",
19+
"uncaughtException",
1820
];
1921
if (allowedChannels.includes(channel)) {
2022
ipcRenderer.send(channel, ...data);
@@ -27,11 +29,11 @@ contextBridge.exposeInMainWorld("api", {
2729
"fromMain",
2830
"add-collection",
2931
"clear-history-response",
30-
"proto-info",
3132
"message",
33+
"proto-info",
3234
"protoParserFunc-return",
33-
"reqResUpdate",
3435
"reply-gql",
36+
"reqResUpdate",
3537
];
3638
if (allowedChannels.includes(channel)) {
3739
ipcRenderer.on(channel, (event, ...args) => cb(...args));

src/client/components/containers/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class App extends Component {
2020
componentDidMount() {
2121
// This file will listen on all of these channels(selectAll, deselectAll, etc) for any communication from the main.js file(aka the main process)
2222
// ipcRenderer.send('check-for-update');
23-
// api.send('check-for-update')
23+
api.send("check-for-update");
2424
// ipcRenderer.on('selectAll', ReqResCtrl.selectAllReqRes); // if the selectAll touchbar button was clicked (then run this method called selectAllReqRes) that is located in the connectionController...likewise for the rest
2525
// ipcRenderer.on('deselectAll', ReqResCtrl.deselectAllReqRes);
2626
// ipcRenderer.on('openAllSelected', ReqResCtrl.openAllSelectedReqRes);

src/client/components/containers/UpdatePopUpContainer.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from "react";
22
import { connect } from "react-redux";
3-
// import { ipcRenderer } from 'electron';
43
const { api } = window;
54

65
const mapDispatchToProps = (dispatch) => ({});
@@ -30,7 +29,6 @@ class UpdatePopUpContainer extends Component {
3029

3130
handleUpdateClick() {
3231
this.toggleShow();
33-
// ipcRenderer.send('quit-and-install');
3432
api.send("quit-and-install");
3533
}
3634

0 commit comments

Comments
 (0)