"use client" import { useEffect } from "react" import { TIER_LIMITS, type SubscriptionTier } from "@asa-news/shared" export function useOfflineAccessSync(tier: SubscriptionTier | undefined) { useEffect(() => { if (!tier) return const allowed = TIER_LIMITS[tier]?.allowsOfflineReading ?? false navigator.serviceWorker?.controller?.postMessage({ type: "SET_OFFLINE_ACCESS", allowed, }) navigator.serviceWorker?.ready.then((registration) => { registration.active?.postMessage({ type: "SET_OFFLINE_ACCESS", allowed, }) }) }, [tier]) }