Skip to content

Commit 6169381

Browse files
committed
chore: checkForUpdates prompts to download v6. bump 5.1.3-alpha
1 parent f36bee4 commit 6169381

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nice-node",
3-
"version": "5.1.0-alpha",
3+
"version": "5.1.3-alpha",
44
"description": "Run a node at home, the easy way.",
55
"homepage": "https://nicenode.xyz",
66
"productName": "NiceNode",

release/app/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nice-node",
3-
"version": "5.1.0-alpha",
3+
"version": "5.1.3-alpha",
44
"description": "Run a node, just press start",
55
"productName": "NiceNode",
66
"main": "./dist/main/main.js",

src/main/updater.ts

+46-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserWindow, dialog } from 'electron';
1+
import { BrowserWindow, dialog, shell } from 'electron';
22
import { autoUpdater, UpdateInfo } from 'electron-updater';
33
import sleep from 'await-sleep';
44

@@ -10,6 +10,7 @@ import { getSetIsPreReleaseUpdatesEnabled } from './state/settings';
1010
let notifyUserIfNoUpdateAvailable: boolean;
1111

1212
const t = i18nMain.getFixedT(null, 'updater');
13+
let pMainWindow: any;
1314

1415
const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
1516
autoUpdater.on('error', (error) => {
@@ -55,14 +56,29 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
5556

5657
autoUpdater.on('update-not-available', () => {
5758
logger.info('autoUpdater:::::::::update-not-available');
58-
if (notifyUserIfNoUpdateAvailable) {
59-
dialog.showMessageBox(browserWindow, {
59+
// always notify user if no update available to download v6+
60+
const downloadUrl = 'https://nicenode.xyz/#download';
61+
dialog
62+
.showMessageBox(browserWindow, {
6063
type: 'info',
61-
title: t('NoUpdateAvailable'),
62-
message: t('NoUpdateAvailable'),
64+
title: t('UpdateAvailable'),
65+
message: `Please download NiceNode version 6 at ${downloadUrl}. Unfortunately, updates from v5 to v6 are not compatible. Automatic updates will work as normal with v6+.`,
66+
buttons: [t('Go to NiceNode downloads'), t('Cancel')],
67+
})
68+
.then(async (buttonIndex) => {
69+
// eslint-disable-next-line promise/always-return
70+
if (buttonIndex.response === 0) {
71+
logger.info('Go to NiceNode download links accepted by user');
72+
shell.openExternal(downloadUrl);
73+
} else {
74+
logger.info('cancel v6 download dialog');
75+
}
76+
})
77+
.catch((err) => {
78+
logger.error(err);
6379
});
64-
notifyUserIfNoUpdateAvailable = false;
65-
}
80+
// avoid removing var work for deprecated v5
81+
console.log(notifyUserIfNoUpdateAvailable);
6682
});
6783

6884
autoUpdater.on('update-downloaded', () => {
@@ -87,6 +103,7 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
87103
};
88104

89105
export const initialize = (mainWindow: BrowserWindow) => {
106+
pMainWindow = mainWindow;
90107
autoUpdater.logger = autoUpdateLogger;
91108
autoUpdater.autoDownload = false;
92109
autoUpdater.autoInstallOnAppQuit = false;
@@ -99,7 +116,28 @@ export const initialize = (mainWindow: BrowserWindow) => {
99116

100117
export const checkForUpdates = (notifyIfNoUpdateAvailable: boolean) => {
101118
notifyUserIfNoUpdateAvailable = notifyIfNoUpdateAvailable;
102-
autoUpdater.checkForUpdatesAndNotify();
119+
// always notify user if no update available to download v6+
120+
const downloadUrl = 'https://nicenode.xyz/#download';
121+
dialog
122+
.showMessageBox(pMainWindow, {
123+
type: 'info',
124+
title: t('UpdateAvailable'),
125+
message: `Please download NiceNode version 6 at ${downloadUrl}. Unfortunately, updates from v5 to v6 are not compatible. Automatic updates will work as normal with v6+.`,
126+
buttons: [t('Go to NiceNode downloads'), t('Cancel')],
127+
})
128+
.then(async (buttonIndex) => {
129+
// eslint-disable-next-line promise/always-return
130+
if (buttonIndex.response === 0) {
131+
logger.info('Go to NiceNode download links accepted by user');
132+
shell.openExternal(downloadUrl);
133+
} else {
134+
logger.info('cancel v6 download dialog');
135+
}
136+
})
137+
.catch((err) => {
138+
logger.error(err);
139+
});
140+
// autoUpdater.checkForUpdatesAndNotify();
103141
};
104142

105143
export const setAllowPrerelease = (isAllowPrerelease: boolean) => {

0 commit comments

Comments
 (0)