Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/improsocial/impro
An extensible Bluesky client for web impro.social
Something went wrong. Try again.
JavaScript
1234567891011121314151617181920212223242526272829303132import { effect } from "/js/signals.js";import { isTouchOnlyDevice } from "/js/utils.js";
export class AppBadgeService { constructor( notificationService, chatNotificationService, pushNotificationService, ) { this.notificationService = notificationService; this.chatNotificationService = chatNotificationService; this.pushNotificationService = pushNotificationService; }
start() { return effect(() => { const activityCount = this.notificationService.$numNotifications.get() ?? 0; const chatCount = this.chatNotificationService.$numNotifications.get() ?? 0; const pushEnabled = this.pushNotificationService?.isEnabled ?? false;
if (!("setAppBadge" in navigator)) return; const badgeEnabled = !isTouchOnlyDevice() || pushEnabled; const total = badgeEnabled ? activityCount + chatCount : 0; const applied = total > 0 ? navigator.setAppBadge(total) : navigator.clearAppBadge(); applied?.catch?.(() => {}); }); }}