Skip to content

Commit b16b3df

Browse files
committed
chore: notify when downloading and finished downloading
1 parent c9dbe76 commit b16b3df

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

package-lock.json

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Dedicated application for loading UnderScript.",
55
"main": "index.js",
66
"scripts": {
7-
"start": "electron .",
7+
"start": "electron --trace-warnings .",
88
"pack": "electron-builder --dir",
99
"dist": "electron-builder",
1010
"postinstall": "electron-builder install-app-deps",
@@ -26,6 +26,7 @@
2626
},
2727
"dependencies": {
2828
"electron-context-menu": "^2.3.1",
29+
"electron-is-dev": "^2.0.0",
2930
"electron-updater": "^4.6.5",
3031
"keytar": "^7.3.0",
3132
"needle": "^2.5.2"

src/electron.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const keytar = require('keytar');
44
const { autoUpdater } = require('electron-updater');
55
const contextMenu = require('electron-context-menu');
66
const checkVersion = require('./underscript');
7+
const isDev = require('electron-is-dev');
78

89
function createWindow() {
910
const win = new BrowserWindow({
@@ -73,6 +74,7 @@ function createWindow() {
7374
}
7475

7576
win.webContents.on('will-navigate', (event, url) => {
77+
if (process.env.LOCAL_DIR) checkVersion().catch(console.error);
7678
const { host, protocol } = new URL(url);
7779
if (host === 'undercards.net') return;
7880

@@ -100,11 +102,21 @@ function createWindow() {
100102
}
101103
});
102104

105+
autoUpdater.autoDownload = true;
106+
autoUpdater.autoInstallOnAppQuit = true;
107+
autoUpdater.on('update-available', (info) => {
108+
toast({
109+
title: 'UnderScript App Update Available',
110+
text: `Now downloading v${info.version}`,
111+
});
112+
});
103113
autoUpdater.on('update-downloaded', (info) => {
104-
toast('Restart to update.');
114+
toast({
115+
title: `UnderScript App Updated: v${info.version}`,
116+
text: `${info.releaseNotes}\n\nRestart App to finish update`
117+
});
105118
});
106-
107-
autoUpdater.checkForUpdatesAndNotify();
119+
if (!isDev) autoUpdater.checkForUpdates();
108120
}
109121

110122
ipcMain.on('set-password', (_, username, password) => keytar.setPassword('UnderScript', username, password));

src/preload/rememberMe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function setup() {
2929
password.addEventListener('focus', () => updatePassword(username.value));
3030

3131
const user = localStorage.getItem('underscript.login.lastUser');
32-
updatePassword(user);
32+
updatePassword(user);
3333
underscript.lib.tippy(document.querySelector('input[name="stayConnected"]').parentElement, {
3434
content: 'Click here to save your username & password!<div style="width:100%;text-align:right;font-size:12px;font-family:monospace;">via UnderScript App</div>',
3535
showOnInit: !user,

0 commit comments

Comments
 (0)