Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show update notify and dialog + Linux icons #97

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ linux:
target:
- AppImage
category: Utility
icon: build/icon.icns
4 changes: 3 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import electron from "electron";
import path from "path";
import { updater } from "./updater";
import { initMenu } from "./menu";
import logger from "./logger";

const app = electron.app;
let mainWindow: electron.BrowserWindow | null;
export let mainWindow: electron.BrowserWindow | null;

process.on("uncaughtException", err => {
logger.error(err);
Expand All @@ -20,6 +21,7 @@ async function createWindow() {
width: 1280,
height: 780,
title: "Bdash",
icon: path.join(__dirname, "..", "icon.png"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webPreferences: {
nodeIntegration: true
}
Expand Down
25 changes: 20 additions & 5 deletions src/main/updater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { autoUpdater, AppUpdater, UpdateCheckResult } from "electron-updater";
import { dialog } from "electron";
import { autoUpdater, AppUpdater, UpdateCheckResult, UpdateInfo } from "electron-updater";
import isDev from "electron-is-dev";
import logger from "./logger";
import { mainWindow } from ".";

autoUpdater.logger = logger;

Expand All @@ -17,14 +19,27 @@ export class Updater {

constructor(autoUpdater: AppUpdater) {
this.autoUpdater = autoUpdater;
this.autoUpdater.on("update-downloaded", () => {
this.autoUpdater.on("update-downloaded", (info: UpdateInfo) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.state = UpdateState.UpdateDownloaded;
if (mainWindow) {
dialog
.showMessageBox(mainWindow, {
type: "info",
buttons: ["Restart", "Later"],
title: "Bdash Update",
message: process.platform === "win32" ? (info.releaseNotes as string) : info.releaseName!,
detail: "A new version has been downloaded. Restart the application to apply the updates."
})
.then(returnValue => {
if (returnValue.response === 0) autoUpdater.quitAndInstall();
});
}
});
}

async check(): Promise<UpdateCheckResult | void> {
if (isDev) return Promise.resolve();
return this.autoUpdater.checkForUpdates();
async check(): Promise<UpdateCheckResult | null> {
if (isDev) return Promise.resolve(null);
return this.autoUpdater.checkForUpdatesAndNotify();
}

async watch(): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = (env, argv) => {
"static/index.js",
"static/RictyDiminished-Regular.ttf",
"static/scatter.svg",
"build/icon.png",
"package.json",
"yarn.lock"
];
Expand Down