Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
repaired update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Beelink committed Sep 29, 2019
1 parent 286ed27 commit ac62b6f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 94 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
2 changes: 1 addition & 1 deletion html/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<button id="reload-btn" class='nav-btn' title="Reload this page" onclick="reload()"><img name="reload-16" class="theme-icon"></button>
<button id="stop-btn" class='nav-btn' title="Stop loading this page" onclick="stop()"><img name="cancel-16" class="theme-icon"></button>
<div class="title-bar-vr"></div>
<button id="info-btn" class='nav-btn' title="Website info" onclick="popupInfoContextMenu()" oncontextmenu="popupInfoContextMenu()"><img name="info-16" class="theme-icon"></button>
<!-- <button id="info-btn" class='nav-btn' title="Website info" onclick="popupInfoContextMenu()" oncontextmenu="popupInfoContextMenu()"><img name="info-16" class="theme-icon"></button> -->
<div id="search-div">
<label id="target-url"></label>
<input type="text" placeholder="Search or type a URL" id="search-input" oninput="goToSearch(this.value, this.selectionStart)" onfocus="focusSearch()">
Expand Down
41 changes: 23 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,35 +95,40 @@ app.on("ready", function() {
autoUpdater.logger = require("electron-log");
autoUpdater.logger.transports.file.level = "info";

autoUpdater.on('checking-for-update', () => {
mainWindow.webContents.send('action-add-status-notif', { type: "info", text: "Checking for updates..." });
autoUpdater.on("checking-for-update", () => {
mainWindow.webContents.send("action-add-status-notif", { type: "info", text: "Checking for updates..." });
});

autoUpdater.on('error', (error) => {
mainWindow.webContents.send('action-add-status-notif', { type: "error", text: "Update error: " + error });
autoUpdater.on("error", (error) => {
mainWindow.webContents.send("action-add-status-notif", { type: "error", text: "Update error: " + error });
});

autoUpdater.on('update-not-available', () => {
mainWindow.webContents.send('action-add-status-notif', { type: "success", text: "App is up to date!" });
autoUpdater.on("update-not-available", () => {
mainWindow.webContents.send("action-add-status-notif", { type: "success", text: "App is up to date!" });
});

autoUpdater.on('update-available', (info) => {
mainWindow.webContents.send('action-add-status-notif', { type: "success", text: "Update is available. Download started..." });
mainWindow.webContents.send('action-add-update-notif', info.releaseName);
autoUpdater.on("update-available", (info) => {
mainWindow.webContents.send("action-add-status-notif", { type: "success", text: `Update is available: "${info.releaseName}". Download started...` });
});

autoUpdater.on('update-downloaded', () => {
mainWindow.webContents.send('action-add-quest-notif', { text: "Update is downloaded!", ops: [{ text:'Install now', icon:'check-16', click:'installUpdate();' }] });
autoUpdater.on("update-downloaded", () => {
mainWindow.webContents.send("action-add-quest-notif", { text: "Update is downloaded!", ops: [{
text: "Install now",
icon: "check-16",
click: "installUpdate();"
}] });
});

autoUpdater.on('download-progress', (progress) => {
autoUpdater.on("download-progress", (progress) => {
if(progress != null) {
mainWindow.webContents.send('action-refresh-update-notif', {
percent: progress.percent,
transferred: progress.transferred,
total: progress.total,
speed: progress.bytesPerSecond
});
let perc = Math.round(progress.percent);
if(perc % 25 == 0 && perc != 100) {
mainWindow.webContents.send("action-add-quest-notif", { text: `Update is being downloaded: ${perc}%`, ops: [{
text: "Cancel",
icon: "cancel-16",
click: "cancelUpdate();"
}] });
}
}
});

Expand Down
23 changes: 0 additions & 23 deletions modules/NotificationManager/NotificationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const TextNotification = require(__dirname + '/Notifications/TextNotification.js
const StatusNotification = require(__dirname + '/Notifications/StatusNotification.js');
const QuestNotification = require(__dirname + '/Notifications/QuestNotification.js');
const ZoomNotification = require(__dirname + '/Notifications/ZoomNotification.js');
const UpdateNotification = require(__dirname + '/Notifications/UpdateNotification.js');

class NotificationManager extends EventEmitter {
maxNotifCount = 1;
Expand Down Expand Up @@ -53,28 +52,6 @@ class NotificationManager extends EventEmitter {
this.appendNotif(new QuestNotification(this.notifCounter++, false, text, buttons));
}

addUpdateNotif(releaseName) {
if(releaseName == null) {
this.appendNotif(new UpdateNotification(this.notifCounter++, false, "Downloading update"));
} else {
this.appendNotif(new UpdateNotification(this.notifCounter++, false, "Downloading update: " + releaseName));
}
}

refreshUpdateNotif(percent, transferred, total, speed) {
let bool = true;
for(let i = 0; i < this.notifArray.length; i++) {
if(this.notifArray[i].constructor.name == "UpdateNotification") {
bool = false;
this.notifArray[i].setProgress(percent, transferred, total, speed);
break;
}
}
if(bool) {
this.addUpdateNotif();
}
}

addZoomNotif(zoom) {
this.appendNotif(new ZoomNotification(this.notifCounter++, true, "Zoom factor changed to " + zoom + "%"));
}
Expand Down
33 changes: 0 additions & 33 deletions modules/NotificationManager/Notifications/UpdateNotification.js

This file was deleted.

19 changes: 0 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,11 @@
"linux": {
"category": "Network",
"target": [
{
"target": "deb",
"arch": [
"x64"
]
},
{
"target": "AppImage",
"arch": [
"x64"
]
},
{
"target": "rpm",
"arch": [
"x64"
]
},
{
"target": "pacman",
"arch": [
"x64",
"ia32"
]
}
]
}
Expand Down

0 comments on commit ac62b6f

Please sign in to comment.