From 9e96fb2366d8638b16a80feb3ec665e899e0c448 Mon Sep 17 00:00:00 2001 From: mhatvan Date: Tue, 6 Jul 2021 10:25:39 +0200 Subject: fix: Rocket.Chat tab doesn't display notifications - bump Rocket.Chat version to v1.0.10 - fix Rocket.Chat direct and indirect messages count --- all.json | 2 +- recipes/rocketchat/package.json | 2 +- recipes/rocketchat/webview.js | 36 +++++++++++++++++++++++------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/all.json b/all.json index 0a1c9ee..7cc4ac7 100644 --- a/all.json +++ b/all.json @@ -1264,7 +1264,7 @@ "featured": false, "id": "rocketchat", "name": "Rocket.Chat", - "version": "1.0.9", + "version": "1.0.10", "icons": { "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/rocketchat/icon.svg" } diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 122a74e..1ac9e9b 100644 --- a/recipes/rocketchat/package.json +++ b/recipes/rocketchat/package.json @@ -1,7 +1,7 @@ { "id": "rocketchat", "name": "Rocket.Chat", - "version": "1.0.9", + "version": "1.0.10", "description": "Rocket.Chat", "main": "index.js", "author": "Stefan Malzner ", diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js index 5ccd0d2..447b19b 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js @@ -1,11 +1,8 @@ -"use strict"; +'use strict'; -const { - ipcRenderer -} = require('electron'); +const { ipcRenderer } = require('electron'); const getTeamIcon = function getTeamIcon() { - console.log('getTeamIcon'); const manifestElement = document.querySelector('link[rel="manifest"]'); if (manifestElement == null) { @@ -13,7 +10,6 @@ const getTeamIcon = function getTeamIcon() { } const manifestUrl = manifestElement.getAttribute('href'); - console.log(manifestUrl); if (manifestUrl == null) { return; @@ -29,7 +25,10 @@ const getTeamIcon = function getTeamIcon() { const response = JSON.parse(this.responseText); if (response.icons.length >= 1) { - ipcRenderer.sendToHost('avatar', `${window.location.protocol}//${window.location.host}${response.icons[0].src}`); + ipcRenderer.sendToHost( + 'avatar', + `${window.location.protocol}//${window.location.host}${response.icons[0].src}` + ); } }; @@ -37,15 +36,26 @@ const getTeamIcon = function getTeamIcon() { xmlhttp.send(); }; -module.exports = Franz => { +module.exports = Ferdi => { const getMessages = function getMessages() { - const directMessages = Math.round(document.querySelectorAll('.unread.unread-mention, .badge--unread').length / 2); - const indirectMessages = Math.round(document.querySelectorAll('.unread:not(.unread-mention), .sidebar-item--unread').length / 2); - Franz.setBadge(directMessages, indirectMessages); + const directMessages = document.querySelectorAll('.rcx-badge'); + + let directMessagesCount = 0; + + for (const directMessage of directMessages) { + directMessagesCount += parseInt(directMessage.textContent, 10); + } + + const indirectMessagesCount = Math.round( + document.querySelectorAll('.rcx-sidebar-item--highlighted').length + ); + + Ferdi.setBadge(directMessagesCount, indirectMessagesCount); }; - Franz.loop(getMessages); + Ferdi.loop(getMessages); + setTimeout(() => { getTeamIcon(); }, 4000); -}; \ No newline at end of file +}; -- cgit v1.2.3-70-g09d2