aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/badge.ts
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-09-14 13:37:47 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-09-14 13:37:47 +0530
commit30ca63d84ccf7fbc378ebf7101f09e10deaf0eaa (patch)
tree27f8ff6265a6fd2a739b8875825504bb86f279f3 /src/webview/badge.ts
parentdocs: updated Changelog [skip ci] (diff)
downloadferdium-app-30ca63d84ccf7fbc378ebf7101f09e10deaf0eaa.tar.gz
ferdium-app-30ca63d84ccf7fbc378ebf7101f09e10deaf0eaa.tar.zst
ferdium-app-30ca63d84ccf7fbc378ebf7101f09e10deaf0eaa.zip
refactor: defensive programming to avoid javascript error for unread badges
Diffstat (limited to 'src/webview/badge.ts')
-rw-r--r--src/webview/badge.ts12
1 files changed, 6 insertions, 6 deletions
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