feat(pwa): app-icon badge with the highlight count via navigator.setAppBadge (#154)
CI / Build & Quality Checks (push) Successful in 1m29s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 11s
CI / Playwright smoke (e2e) (push) Successful in 2m4s
CI / Build & Quality Checks (push) Successful in 1m29s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 11s
CI / Playwright smoke (e2e) (push) Successful in 2m4s
Same number as the tab title (leaf-room highlights), cleared at zero. Skipped under Tauri where the native set_badge_count owns the badge, and silently absent where the Badging API is not available. Closes #154 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -59,7 +59,7 @@ import { toastQueueAtom } from '../../state/toast';
|
||||
import { useReminders } from '../../hooks/useReminders';
|
||||
import { getRoomRetentionMs, isExpired } from '../../utils/retention';
|
||||
import { useTauriUpdater } from '../../hooks/useTauriUpdater';
|
||||
import { invokeTauri } from '../../hooks/useTauri';
|
||||
import { invokeTauri, isTauri as isTauriApp } from '../../hooks/useTauri';
|
||||
import { TauriDesktopFeatures } from '../../components/TauriDesktopFeatures';
|
||||
import { KeyboardShortcutsDialog, useKeyboardShortcutsTrigger } from '../../features/shortcuts';
|
||||
import { useRoomsListener } from '../../hooks/useRoomsListener';
|
||||
@@ -153,6 +153,23 @@ function FaviconUpdater() {
|
||||
} else {
|
||||
document.title = 'Lotus Chat';
|
||||
}
|
||||
|
||||
// [Gitea #154] Installed-PWA app-icon badge (Android Chrome, desktop
|
||||
// Chrome/Edge). Same number as the title so the two never disagree:
|
||||
// highlights only, mirroring the desktop app's native `set_badge_count`
|
||||
// (which owns the badge under Tauri, so skip there). Plain tabs and
|
||||
// browsers without the Badging API simply have no `setAppBadge`.
|
||||
if (!isTauriApp()) {
|
||||
const nav = navigator as Navigator & {
|
||||
setAppBadge?: (count?: number) => Promise<void>;
|
||||
clearAppBadge?: () => Promise<void>;
|
||||
};
|
||||
if (totalHighlight > 0) {
|
||||
nav.setAppBadge?.(totalHighlight).catch(() => {});
|
||||
} else {
|
||||
nav.clearAppBadge?.().catch(() => {});
|
||||
}
|
||||
}
|
||||
}, [roomToUnread]);
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user