Skip to content

Commit

Permalink
Fix unread counts in gmail
Browse files Browse the repository at this point in the history
  • Loading branch information
vraravam committed Jan 15, 2024
1 parent 3f3e7be commit 415ab07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion recipes/gmail/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "gmail",
"name": "Gmail",
"version": "1.6.1",
"version": "1.6.2",
"license": "MIT",
"config": {
"serviceURL": "https://mail.google.com"
Expand Down
18 changes: 8 additions & 10 deletions recipes/gmail/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ module.exports = Ferdium => {
const inboxLinks = document.querySelectorAll('.J-Ke.n0');
const spaceAndChatBadges = document.querySelectorAll('span.XU.aH6');

if (inboxLinks.length > 0) {
if (spaceAndChatBadges.length > 0) {
const arr = [...spaceAndChatBadges];
const spaceAndChatCount = arr.reduce(
(acc, e) => Ferdium.safeParseInt(e.getInnerHTML()) + acc,
0,
);
countImportant += spaceAndChatCount;
} else if (inboxLinks.length > 0) {
const { parentNode } = inboxLinks[0];
if (parentNode) {
const parentNodeOfParentNode = parentNode.parentNode;
Expand All @@ -44,15 +51,6 @@ module.exports = Ferdium => {
}
}

if (spaceAndChatBadges.length > 0) {
const arr = [...spaceAndChatBadges];
const spaceAndChatCount = arr.reduce(
(acc, e) => Ferdium.safeParseInt(e.getInnerHTML()) + acc,
0,
);
countImportant += spaceAndChatCount;
}

Ferdium.setBadge(countImportant, countNonImportant);
};

Expand Down

0 comments on commit 415ab07

Please sign in to comment.