From 1391bd57d041e91b53c09cd297d7774762699d88 Mon Sep 17 00:00:00 2001 From: Daniel Peukert Date: Thu, 16 Dec 2021 11:52:34 +0100 Subject: Fix Rainloop unread counter (#788) --- all.json | 2 +- recipes/rainloop/package.json | 2 +- recipes/rainloop/webview.js | 27 ++++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/all.json b/all.json index 9cd2609..aa6bf1c 100644 --- a/all.json +++ b/all.json @@ -1386,7 +1386,7 @@ "featured": false, "id": "rainloop", "name": "RainLoop", - "version": "1.1.1", + "version": "1.1.2", "icons": { "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/rainloop/icon.svg" } diff --git a/recipes/rainloop/package.json b/recipes/rainloop/package.json index 04b6674..79deb2d 100644 --- a/recipes/rainloop/package.json +++ b/recipes/rainloop/package.json @@ -1,7 +1,7 @@ { "id": "rainloop", "name": "RainLoop", - "version": "1.1.1", + "version": "1.1.2", "repository": "https://github.com/promarcel/franz-recipe-rainloop", "license": "MIT", "config": { diff --git a/recipes/rainloop/webview.js b/recipes/rainloop/webview.js index 346e51f..0a29849 100644 --- a/recipes/rainloop/webview.js +++ b/recipes/rainloop/webview.js @@ -1,24 +1,25 @@ module.exports = Ferdi => { const getMessages = () => { - let updates = 0; - let inbox = 0; - let full = 0; + let messages = 0; - $('.b-folders-user .ui-droppable').each((i, obj) => { - const countText = $(obj).find('.count').first().html(); - if (typeof countText === 'string' && countText !== '') { - if ($(obj).hasClass('system')) { - if ($(obj).hasClass('i-am-inbox')) { - inbox += Ferdi.safeParseInt(countText); + // Let's only loop through user folders, as all system folders are duplicated there + for (const obj of document.querySelectorAll('.b-folders-user .ui-droppable')) { + const countEl = obj.querySelector('.count'); + const countText = countEl ? countEl.innerHTML : ''; + + if (countText != '') { + if (obj.classList.contains('system')) { + // Only count the Inbox system folder and ignore Archive, Trash, Drafts, Spam, Sent + if (obj.classList.contains('i-am-inbox')) { + messages += Ferdi.safeParseInt(countText); } } else { - updates += Ferdi.safeParseInt(countText); + messages += Ferdi.safeParseInt(countText); } } - }); + } - full = inbox + updates; - Ferdi.setBadge(full); + Ferdi.setBadge(messages); }; Ferdi.loop(getMessages); -- cgit v1.2.3-54-g00ecf