export type AutoSyncMode = "none" | "scrobbles" | "all"; export const backgroundSyncTag = "tinysub-auto-sync"; export const backgroundSyncRequestMessage = "TINYSUB_BACKGROUND_SYNC"; export const backgroundSyncConfigMessage = "TINYSUB_BACKGROUND_SYNC_CONFIG"; export const isAutoSyncEligible = (method: string, mode: AutoSyncMode) => mode === "all" || (mode === "scrobbles" && method === "scrobble"); export const updateAppBadge = async (count: number) => { if (typeof globalThis.navigator === "undefined") return; const nav = globalThis.navigator as { setAppBadge?: (contents?: number) => Promise; clearAppBadge?: () => Promise; }; try { if (count > 0) await nav.setAppBadge?.(count); else await nav.clearAppBadge?.(); } catch {} };