commit: 77e270ef58750bb06955b7f45bd63382704928a5
parent f449bfe2f1d77172aee0433f63ec4a82bcc7ea1e
Author: Henry Jameson <me@hjkos.com>
Date: Thu, 9 Nov 2023 01:53:48 +0200
Don't use notification-badge'd favicon for badges in notifications
Diffstat:
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
@@ -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
@@ -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