Notifications push (Web Push) et indicateur hors-ligne / synchro en attente

- Réglages → Notifications : interrupteur « Notifications sur cet appareil »
  (permission demandée au clic uniquement, iOS : explication « installe l'app »,
  permission refusée, navigateur non compatible). Désinscription à la déconnexion.
- Service worker : push-sw.js chargé via workbox.importScripts (affichage +
  clic qui ouvre/focalise l'app sur le bon écran via « /?open=… »).
- Serveur : table push_subscriptions (RLS, anti-SSRF, 10 appareils max),
  déclencheur pg_net + secret dans Vault, fonction send-push (aes128gcm +
  VAPID ES256 en WebCrypto, testée sur le vecteur RFC 8291), regroupement des
  épisodes, préférences notifPrefs, ménage des abonnements expirés.
- scripts/gen-vapid.mjs et supabase/PUSH_SETUP.md (étapes manuelles).
- Pastille discrète hors-ligne / « N modifications en attente » (mobile au-dessus
  de la barre de nav, ordinateur dans la barre latérale), basée sur l'état du
  moteur de synchro existant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-10-09 15:21:17 +00:00
1 parent c246b16e7e
commit 6f7064f53f
35 files changed
+1779

No files matched your search

+4
View File
@@ -9,6 +9,7 @@ import { createSync, type SyncEngine, type SyncStatus } from './lib/cloud/sync'
import { deleteDatabase, readOtherDatabase } from './lib/db'
import { cloudFetch } from './lib/cloud/api'
import { signOut } from './lib/cloud/auth'
import { disablePush, forgetPushLocally } from './lib/push'
import { dbNameFor, scopedKey } from './lib/scope'
import { isPlainObject, LIMITS, readStorage, storageGet, storageSet } from './lib/security'
import { mediaDB, requestPersistentStorage } from './lib/db'
@@ -396,6 +397,8 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
if (engine && navigator.onLine) await engine.syncNow()
if (!force && engine && engine.status().pending > 0) return 'pending'
engine?.stop()
// Cet appareil ne doit plus recevoir les notifications push de ce compte
await disablePush().catch(() => {})
await wipeAccountFromDevice(userId)
await signOut()
return 'done'
@@ -408,6 +411,7 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
})
if (!res.ok) throw new Error(res.status === 429 ? t('account.err.deleteRate') : t('account.err.delete'))
syncRef.current?.stop()
await forgetPushLocally().catch(() => {})
await wipeAccountFromDevice(userId)
await signOut()
},