Skip to content

Commit 7fba838

Browse files
committed
Add Minimal AutoUpdater functionality 🤖
1 parent ae0c4e7 commit 7fba838

File tree

3 files changed

+15
-48
lines changed

3 files changed

+15
-48
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "wip-desktop",
2+
"name": "WIP Desktop",
33
"description": "Desktop Application for WIP Chat",
44
"author": {
55
"email": "akshaykadam0904@gmail.com",
@@ -11,7 +11,7 @@
1111
"url": "https://github.com/deadcoder0904/wip-desktop.git"
1212
},
1313
"homepage": "https://akshaykadam.me/apps/wip-desktop",
14-
"version": "1.2.0",
14+
"version": "1.3.0",
1515
"license": "MIT",
1616
"scripts": {
1717
"dev": "electron-webpack dev",

src/main/autoUpdater.js

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
1-
// import { autoUpdater } from "electron-updater";
2-
// import log from "electron-log";
3-
4-
// export const electronUpdater = win => {
5-
// autoUpdater.logger = log;
6-
// autoUpdater.logger.transports.file.level = "info";
7-
// log.info("App starting...");
8-
9-
// function sendStatusToWindow(text) {
10-
// log.info(text);
11-
// win.webContents.send("autoupdater-message", text);
12-
// }
13-
14-
// autoUpdater.on("checking-for-update", () => {
15-
// sendStatusToWindow("Checking for update...");
16-
// });
17-
18-
// autoUpdater.on("update-available", info => {
19-
// sendStatusToWindow("Update available.");
20-
// });
21-
22-
// autoUpdater.on("update-not-available", info => {
23-
// sendStatusToWindow("Update not available.");
24-
// });
25-
26-
// autoUpdater.on("error", err => {
27-
// sendStatusToWindow("Error in auto-updater. " + err);
28-
// });
29-
30-
// autoUpdater.on("download-progress", progressObj => {
31-
// const log_message = `Download speed: ${
32-
// progressObj.bytesPerSecond
33-
// } - Downloaded ${progressObj.percent} % ${log_message} ( ${
34-
// progressObj.transferred
35-
// } / ${progressObj.total} )`;
36-
// sendStatusToWindow(log_message);
37-
// });
38-
39-
// autoUpdater.on("update-downloaded", info => {
40-
// sendStatusToWindow("Update downloaded");
41-
// });
42-
// };
1+
import { autoUpdater } from "electron-updater";
2+
import log from "electron-log";
3+
4+
export class AppUpdater {
5+
constructor() {
6+
const log = require("electron-log");
7+
log.transports.file.level = "info";
8+
autoUpdater.logger = log;
9+
autoUpdater.checkForUpdatesAndNotify();
10+
}
11+
}

src/main/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { app, BrowserWindow, Menu, shell } from "electron";
22
import * as path from "path";
33
import { format as formatUrl } from "url";
44
import { answerRenderer, callRenderer } from "electron-better-ipc";
5-
import { autoUpdater } from "electron-updater";
65
const isDevelopment = process.env.NODE_ENV !== "production";
76

87
import { createMenu } from "./menu";
98
import { createMainWindow } from "./createWindow";
10-
// import { electronUpdater } from "./autoUpdater";
9+
import { AppUpdater } from "./autoUpdater";
1110

1211
// global reference to mainWindow (necessary to prevent window from being garbage collected)
1312
let mainWindow;
@@ -31,8 +30,7 @@ app.on("activate", () => {
3130
app.on("ready", () => {
3231
mainWindow = createMainWindow(mainWindow);
3332
createMenu();
34-
// electronUpdater(mainWindow);
35-
autoUpdater.checkForUpdatesAndNotify();
33+
new AppUpdater();
3634
});
3735

3836
answerRenderer("app-quit", () => {

0 commit comments

Comments
 (0)