aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md8
-rw-r--r--src/webview/badge.ts12
-rw-r--r--src/webview/lib/RecipeWebview.js12
3 files changed, 19 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4cdab88fd..0e6f12af9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,10 @@
1# [v5.6.3-nightly.2](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.0...v5.6.3-nightly.2) (2021-09-14) 1# [v5.6.3-nightly.3](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.2...v5.6.3-nightly.3) (2021-09-15)
2
3### Under the hood
4
5- Defensive programming to avoid javascript error for unread badges 💖 @vraravam
6
7# [v5.6.3-nightly.2](https://github.com/getferdi/ferdi/compare/v5.6.2...v5.6.3-nightly.2) (2021-09-14)
2 8
3### Features 9### Features
4 10
diff --git a/src/webview/badge.ts b/src/webview/badge.ts
index 753e90fef..024e29b3f 100644
--- a/src/webview/badge.ts
+++ b/src/webview/badge.ts
@@ -26,17 +26,17 @@ export class BadgeHandler {
26 return Math.max(adjustedNumber, 0); 26 return Math.max(adjustedNumber, 0);
27 } 27 }
28 28
29 setBadge(direct: string | number, indirect: string | number) { 29 setBadge(direct: string | number | undefined | null, indirect: string | number | undefined | null) {
30 if (this.countCache.direct.toString() === direct.toString()
31 && this.countCache.indirect.toString() === indirect.toString()) {
32 return;
33 }
34
35 const count = { 30 const count = {
36 direct: this.safeParseInt(direct), 31 direct: this.safeParseInt(direct),
37 indirect: this.safeParseInt(indirect), 32 indirect: this.safeParseInt(indirect),
38 }; 33 };
39 34
35 if (this.countCache.direct.toString() === count.direct.toString()
36 && this.countCache.indirect.toString() === count.indirect.toString()) {
37 return;
38 }
39
40 debug('Sending badge count to host', count); 40 debug('Sending badge count to host', count);
41 ipcRenderer.sendToHost('message-counts', count); 41 ipcRenderer.sendToHost('message-counts', count);
42 42
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js
index 2bd6bad8d..157da7693 100644
--- a/src/webview/lib/RecipeWebview.js
+++ b/src/webview/lib/RecipeWebview.js
@@ -35,12 +35,12 @@ class RecipeWebview {
35 /** 35 /**
36 * Set the unread message badge 36 * Set the unread message badge
37 * 37 *
38 * @param {int} direct Set the count of direct messages 38 * @param {string | number | undefined | null} direct Set the count of direct messages
39 * eg. Slack direct mentions, or a 39 * eg. Slack direct mentions, or a
40 * message to @channel 40 * message to @channel
41 * @param {int} indirect Set a badge that defines there are 41 * @param {string | number | undefined | null} indirect Set a badge that defines there are
42 * new messages but they do not involve 42 * new messages but they do not involve
43 * me directly to me eg. in a channel 43 * me directly to me eg. in a channel
44 */ 44 */
45 setBadge(direct = 0, indirect = 0) { 45 setBadge(direct = 0, indirect = 0) {
46 this.badgeHandler.setBadge(direct, indirect); 46 this.badgeHandler.setBadge(direct, indirect);