From 77e270ef58750bb06955b7f45bd63382704928a5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 9 Nov 2023 01:53:48 +0200 Subject: [PATCH] Don't use notification-badge'd favicon for badges in notifications --- src/services/favicon_service/favicon_service.js | 5 ++++- src/services/notification_utils/notification_utils.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/services/favicon_service/favicon_service.js b/src/services/favicon_service/favicon_service.js index 7e19629d98..df603bb464 100644 --- a/src/services/favicon_service/favicon_service.js +++ b/src/services/favicon_service/favicon_service.js @@ -55,10 +55,13 @@ const createFaviconService = () => { }) } + const getOriginalFavicons = () => [...favicons] + return { initFaviconService, clearFaviconBadge, - drawFaviconBadge + drawFaviconBadge, + getOriginalFavicons } } diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index 8842b8e40c..4c6c4d8aef 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -1,6 +1,9 @@ import { filter, sortBy, includes } from 'lodash' import { muteWordHits } from '../status_parser/status_parser.js' import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js' +import FaviconService from 'src/services/favicon_service/favicon_service.js' + +let cachedBadgeUrl = null export const notificationsFromStore = store => store.state.statuses.notifications.data @@ -76,12 +79,14 @@ export const unseenNotificationsFromStore = store => filter(filteredNotificationsFromStore(store), ({ seen }) => !seen) export const prepareNotificationObject = (notification, i18n) => { - const nodes = document.querySelectorAll('link[rel="icon"]') - const badge = nodes[0].href + if (cachedBadgeUrl === null) { + const favicon = FaviconService.getOriginalFavicons()[0] + cachedBadgeUrl = favicon.favcanvas.toDataURL() + } const notifObj = { tag: notification.id, - badge + badge: cachedBadgeUrl } const status = notification.status const title = notification.from_profile.name