feat(pwa): badge the installed app icon with unread count (Badging API) - #934
Open
dev-hive-kazniisa wants to merge 1 commit into
Open
feat(pwa): badge the installed app icon with unread count (Badging API)#934dev-hive-kazniisa wants to merge 1 commit into
dev-hive-kazniisa wants to merge 1 commit into
Conversation
Adds useAppBadge alongside the existing useFaviconBadge, mounted from the same FaviconBadge component and gated by the same faviconUnreadBadge setting. Targets the separate icon Chrome/Edge/WebKit show for an installed PWA (taskbar/dock/Home Screen/pinned-app-shortcut), which does not react to favicon changes at all - a merely pinned browser tab is unaffected, only an actually installed app. No unmount cleanup: the badge is scoped to the installed app/origin, not to this component or window, so clearing on every unmount would blank another still-open window's accurate badge. A count of zero or the setting being off already clears it through the main effect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
useAppBadge, which mirrors the existing favicon unread badge onto the installed app icon via the Badging API (navigator.setAppBadge/clearAppBadge).Chrome, Edge and WebKit render a separate icon for an installed PWA — taskbar, dock, Home Screen, pinned app shortcut — and that icon does not react to favicon changes at all. So a user who installs Bulwark as an app currently loses the unread indicator that tab users get. A merely pinned browser tab is unaffected either way; this only touches an actually installed app.
How
hooks/use-app-badge.ts, mounted from the sameFaviconBadgecomponent and gated by the samefaviconUnreadBadgesetting — no new setting, no new i18n keys.i18n
No new keys. The existing
favicon_unread_badgelabel/description wording inennow mentions the app icon as well, and therutranslation for that key is filled in (it was still English). Per CONTRIBUTING, the other 22 locales fall back to English for the reworded string — happy to add them in this PR or a follow-up if you'd prefer them updated now.Tests
hooks/__tests__/use-app-badge.test.tsx(new, 9 cases) and 4 added cases incomponents/__tests__/favicon-badge.test.tsx— 13 passing.npm run typecheckandnpm run lintclean.Notes
Running in production on a ~280-mailbox Stalwart deployment since 2026-08-14.