Don't use notification-badge'd favicon for badges in notifications

このコミットが含まれているのは:
Henry Jameson 2023-11-09 01:53:48 +02:00
コミット 77e270ef58
2個のファイルの変更12行の追加4行の削除

ファイルの表示

@ -55,10 +55,13 @@ const createFaviconService = () => {
}) })
} }
const getOriginalFavicons = () => [...favicons]
return { return {
initFaviconService, initFaviconService,
clearFaviconBadge, clearFaviconBadge,
drawFaviconBadge drawFaviconBadge,
getOriginalFavicons
} }
} }

ファイルの表示

@ -1,6 +1,9 @@
import { filter, sortBy, includes } from 'lodash' import { filter, sortBy, includes } from 'lodash'
import { muteWordHits } from '../status_parser/status_parser.js' import { muteWordHits } from '../status_parser/status_parser.js'
import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.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 export const notificationsFromStore = store => store.state.statuses.notifications.data
@ -76,12 +79,14 @@ export const unseenNotificationsFromStore = store =>
filter(filteredNotificationsFromStore(store), ({ seen }) => !seen) filter(filteredNotificationsFromStore(store), ({ seen }) => !seen)
export const prepareNotificationObject = (notification, i18n) => { export const prepareNotificationObject = (notification, i18n) => {
const nodes = document.querySelectorAll('link[rel="icon"]') if (cachedBadgeUrl === null) {
const badge = nodes[0].href const favicon = FaviconService.getOriginalFavicons()[0]
cachedBadgeUrl = favicon.favcanvas.toDataURL()
}
const notifObj = { const notifObj = {
tag: notification.id, tag: notification.id,
badge badge: cachedBadgeUrl
} }
const status = notification.status const status = notification.status
const title = notification.from_profile.name const title = notification.from_profile.name