TelegramPWA/src/util/appBadge.ts
2023-01-28 02:21:33 +01:00

18 lines
479 B
TypeScript

import { DEBUG } from '../config';
import { getGlobal } from '../global';
import { selectTabState } from '../global/selectors';
export function updateAppBadge(unreadCount: number) {
if (!selectTabState(getGlobal()).isMasterTab) return;
if (typeof window.navigator.setAppBadge !== 'function') {
return;
}
window.navigator.setAppBadge(unreadCount).catch((err) => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.error(err);
}
});
}