diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers/url-helpers.ts | 2 | ||||
-rw-r--r-- | src/index.js | 1 | ||||
-rw-r--r-- | src/webview/badge.js | 19 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts index e330fae40..3657ae693 100644 --- a/src/helpers/url-helpers.ts +++ b/src/helpers/url-helpers.ts | |||
@@ -30,7 +30,7 @@ export async function openPath(folderName: string) { | |||
30 | 30 | ||
31 | // TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check | 31 | // TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check |
32 | export function openExternalUrl(url: string | URL, skipValidityCheck: boolean = false) { | 32 | export function openExternalUrl(url: string | URL, skipValidityCheck: boolean = false) { |
33 | debug('for url:', url, 'skipValidityCheck:', skipValidityCheck); | 33 | debug('Open url:', url, 'with skipValidityCheck:', skipValidityCheck); |
34 | if (skipValidityCheck || isValidExternalURL(url)) { | 34 | if (skipValidityCheck || isValidExternalURL(url)) { |
35 | shell.openExternal(url.toString()); | 35 | shell.openExternal(url.toString()); |
36 | } | 36 | } |
diff --git a/src/index.js b/src/index.js index 563ad08ed..7634fd35b 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -342,7 +342,6 @@ const createWindow = () => { | |||
342 | app.isMaximized = mainWindow.isMaximized(); | 342 | app.isMaximized = mainWindow.isMaximized(); |
343 | 343 | ||
344 | mainWindow.webContents.on('new-window', (e, url) => { | 344 | mainWindow.webContents.on('new-window', (e, url) => { |
345 | debug('Open url', url); | ||
346 | e.preventDefault(); | 345 | e.preventDefault(); |
347 | openExternalUrl(url); | 346 | openExternalUrl(url); |
348 | }); | 347 | }); |
diff --git a/src/webview/badge.js b/src/webview/badge.js index 1e02fb56a..6be4cf609 100644 --- a/src/webview/badge.js +++ b/src/webview/badge.js | |||
@@ -10,19 +10,22 @@ export class BadgeHandler { | |||
10 | }; | 10 | }; |
11 | } | 11 | } |
12 | 12 | ||
13 | setBadge(direct, indirect) { | 13 | _normalizeNumber(count) { |
14 | if (this.countCache.direct === direct | ||
15 | && this.countCache.indirect === indirect) return; | ||
16 | |||
17 | // Parse number to integer | 14 | // Parse number to integer |
18 | // This will correct errors that recipes may introduce, e.g. | 15 | // This will correct errors that recipes may introduce, e.g. |
19 | // by sending a String instead of an integer | 16 | // by sending a String instead of an integer |
20 | const directInt = parseInt(direct, 10); | 17 | const parsedNumber = parseInt(count, 10); |
21 | const indirectInt = parseInt(indirect, 10); | 18 | const adjustedNumber = Number.isNaN(parsedNumber) ? 0 : parsedNumber; |
19 | return Math.max(adjustedNumber, 0); | ||
20 | } | ||
21 | |||
22 | setBadge(direct, indirect) { | ||
23 | if (this.countCache.direct === direct | ||
24 | && this.countCache.indirect === indirect) return; | ||
22 | 25 | ||
23 | const count = { | 26 | const count = { |
24 | direct: Math.max(directInt, 0), | 27 | direct: this._normalizeNumber(direct), |
25 | indirect: Math.max(indirectInt, 0), | 28 | indirect: this._normalizeNumber(indirect), |
26 | }; | 29 | }; |
27 | 30 | ||
28 | ipcRenderer.sendToHost('message-counts', count); | 31 | ipcRenderer.sendToHost('message-counts', count); |