Suppression du système de notifications

- Plus de cloche sur l'accueil ni de panneau de notifications.
- Plus de notifications push : réglage retiré, service worker sans push-sw.js,
  fonction send-push et script VAPID supprimés du dépôt.
- Réglages « Notifications » retirés (et notifPrefs des réglages synchronisés).
- Plus d'envoi des nouveaux épisodes au serveur pour les notifications.
- Au lancement, l'appli résilie l'ancien abonnement push de l'appareil s'il en reste un.
- Textes retirés des 18 langues ; politique de confidentialité mise à jour.
- Serveur : migration 20261122120000_remove_notifications.sql (déjà appliquée en ligne) :
  plus aucune notification créée ni envoyée, données vidées.
- Les demandes d'abonnement et invitations aux listes restent accessibles
  depuis le profil et les listes partagées.

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-11-22 17:04:40 +00:00
1 parent 3eb8d4651c
commit dba91678bd
43 files changed
+62 -2298

No files matched your search

-75
View File
@@ -1,75 +0,0 @@
import { useEffect, useRef, useState } from 'react'
import { keepPushFresh } from '../lib/push'
import { useMedia } from '../store'
import { useSocial } from './social/SocialProvider'
/** Écrans qu'une notification push peut ouvrir (« /?open=… », voir public/push-sw.js). */
const OPEN_RE = /^(notifications|item:[A-Za-z0-9_-]{1,64}|u:[a-z0-9_]{3,20})$/
/** Lit (et retire de l'adresse) l'écran demandé par une notification au lancement de l'app. */
function takeOpenParam(): string | null {
try {
const params = new URLSearchParams(location.search)
const open = params.get('open')
if (open === null) return null
params.delete('open')
const q = params.toString()
history.replaceState(history.state, '', `${location.pathname}${q ? `?${q}` : ''}${location.hash}`)
return OPEN_RE.test(open) ? open : null
} catch {
return null
}
}
/**
* Lien entre les notifications push et l'app : ouvre le bon écran au clic sur une notification
* (app lancée, ou déjà ouverte : message du service worker), met à jour la cloche quand
* une notification arrive, et garde l'abonnement de l'appareil à jour côté serveur.
*/
export default function PushBridge() {
const { account, items, loading } = useMedia()
const social = useSocial()
const [target, setTarget] = useState<string | null>(takeOpenParam)
const socialRef = useRef(social)
socialRef.current = social
// Messages du service worker
useEffect(() => {
if (!('serviceWorker' in navigator)) return
const onMessage = (e: MessageEvent) => {
const data = e.data as { type?: unknown; open?: unknown } | null
if (!data || typeof data !== 'object') return
if (data.type === 'azuu:open' && typeof data.open === 'string' && OPEN_RE.test(data.open)) setTarget(data.open)
else if (data.type === 'azuu:push') void socialRef.current.refresh()
}
navigator.serviceWorker.addEventListener('message', onMessage)
return () => navigator.serviceWorker.removeEventListener('message', onMessage)
}, [])
// Ouvre l'écran demandé une fois le compte et la bibliothèque chargés
useEffect(() => {
if (!target) return
if (!account) {
// Pas (ou plus) connecté : rien à ouvrir
if (!loading) setTarget(null)
return
}
if (!social.enabled || loading) return
setTarget(null)
if (target === 'notifications') social.openNotifications()
else if (target.startsWith('u:')) social.openProfile(target.slice(2))
else {
const item = items.find((i) => i.id === target.slice(5))
if (item) social.openItem(item)
else social.openNotifications()
}
}, [target, account, social, loading, items])
// Abonnement push renouvelé par le navigateur, langue changée… : on le signale au serveur
const accountOn = !!account
useEffect(() => {
if (accountOn) void keepPushFresh()
}, [accountOn])
return null
}
-85
View File
@@ -1,85 +0,0 @@
import { BellRing, Loader2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t } from '../i18n'
import { enablePush, disablePush, getPushState, PushError, type PushState } from '../lib/push'
import { cx } from '../lib/utils'
/** Réglages → Notifications : « Notifications sur cet appareil » (Web Push, même app fermée). */
export default function PushToggle() {
const [state, setState] = useState<PushState | null>(null)
const [busy, setBusy] = useState(false)
const [error, setError] = useState<string | null>(null)
useEffect(() => {
let alive = true
void getPushState().then((s) => alive && setState(s))
return () => {
alive = false
}
}, [])
if (state === null) return null
const on = state === 'on'
const available = state === 'on' || state === 'off'
const toggle = async () => {
if (busy || !available) return
setBusy(true)
setError(null)
try {
if (on) {
await disablePush()
setState('off')
} else {
// La permission n'est demandée qu'ici, au clic
setState(await enablePush())
}
} catch (e) {
const code = e instanceof PushError ? e.code : 'failed'
if (code === 'denied') setState('denied')
else setError(code === 'not-ready' ? t('push.notReady') : t('push.error'))
} finally {
setBusy(false)
}
}
const hint =
state === 'needs-install'
? t('push.iosInstall')
: state === 'unsupported'
? t('push.unsupported')
: state === 'denied'
? t('push.denied')
: t('push.deviceHint')
return (
<div className="card mb-3 overflow-hidden">
<button
type="button"
role="switch"
aria-checked={on}
aria-disabled={!available || busy}
onClick={() => void toggle()}
className={cx('flex w-full items-center gap-3.5 px-4 py-3.5 text-start', !available && 'cursor-default')}
>
<span className={cx('grid size-10 shrink-0 place-items-center rounded-full bg-surface-2', on ? 'text-accent' : 'text-ink-2')}>
{busy ? <Loader2 size={18} className="animate-spin" /> : <BellRing size={18} />}
</span>
<span className="min-w-0 flex-1">
<span className="block text-sm font-medium">{t('push.device')}</span>
<span className={cx('mt-0.5 block text-xs', state === 'denied' ? 'text-accent' : 'text-ink-3')}>{hint}</span>
</span>
{available && (
<span className={cx('relative h-6 w-11 shrink-0 rounded-full transition-colors', on ? 'bg-accent-fill' : 'border border-line-strong bg-surface-2')}>
<span className={cx('absolute top-0.5 size-5 rounded-full bg-ink transition-all', on ? 'start-[22px] bg-on-accent' : 'start-0.5')} />
</span>
)}
</button>
{error && (
<p role="alert" className="border-t border-line px-4 py-2.5 text-xs text-accent">
{error}
</p>
)}
</div>
)
}
-289
View File
@@ -1,289 +0,0 @@
import { Check, Loader2, MessageCircle, Tv, Users } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t } from '../../i18n'
import { listNotifications, markNotificationsRead, type AppNotification, type NotificationKind } from '../../lib/cloud/notifications'
import { cx, formatDate } from '../../lib/utils'
import { EmptyState } from '../ui'
import Avatar from './Avatar'
import { respondToInvite } from '../../lib/cloud/sharedLists'
import { useSocial } from './SocialProvider'
import Sheet from './Sheet'
const PAGE = 30
const FOLLOW_KINDS: NotificationKind[] = ['follow_request', 'follow_accepted', 'new_follower']
const EPISODE_KINDS: NotificationKind[] = ['new_episode', 'new_season']
const VERB: Record<NotificationKind, () => string> = {
follow_request: () => t('notif.follow_request'),
follow_accepted: () => t('notif.follow_accepted'),
new_follower: () => t('notif.new_follower'),
reaction: () => t('notif.reaction'),
new_episode: () => '',
new_season: () => '',
review_comment: () => t('notif.review_comment'),
shared_list_invite: () => t('notif.shared_list_invite'),
}
/** Liste des notifications (abonnements, réactions, nouveaux épisodes). Marque comme lues à l'ouverture. */
export default function Notifications({
onClose,
onOpenProfile,
onOpenItem,
onOpenComments,
onOpenSharedList,
}: {
onClose: () => void
onOpenProfile: (username: string) => void
onOpenItem: (itemId: string) => void
onOpenComments?: (itemId: string, title: string) => void
onOpenSharedList?: (listId: string) => void
}) {
const [items, setItems] = useState<AppNotification[] | undefined>(undefined)
const [done, setDone] = useState(false)
const [loadingMore, setLoadingMore] = useState(false)
useEffect(() => {
let alive = true
void (async () => {
try {
const page = await listNotifications(0)
if (!alive) return
setItems(page)
setDone(page.length < PAGE)
} catch {
if (alive) {
setItems([])
setDone(true)
}
}
markNotificationsRead().catch(() => {})
})()
return () => {
alive = false
}
}, [])
const loadMore = async () => {
if (!items || loadingMore) return
setLoadingMore(true)
try {
const page = await listNotifications(items.length)
setItems((prev) => [...(prev ?? []), ...page])
setDone(page.length < PAGE)
} catch {
setDone(true)
} finally {
setLoadingMore(false)
}
}
return (
<Sheet title={t('notif.title')} label={t('notif.title')} onClose={onClose} elevated>
{items === undefined ? (
<p className="flex items-center justify-center py-16 text-ink-3">
<Loader2 size={20} className="animate-spin" />
</p>
) : items.length === 0 ? (
<div className="px-4">
<EmptyState title={t('notif.empty')} />
</div>
) : (
<ul>
{items.map((n) => (
<Row key={n.id} n={n} onOpenProfile={onOpenProfile} onOpenItem={onOpenItem} onOpenComments={onOpenComments} onOpenSharedList={onOpenSharedList} />
))}
{!done && (
<li className="p-4">
<button onClick={loadMore} disabled={loadingMore} className="btn btn-ghost w-full">
{loadingMore ? <Loader2 size={15} className="animate-spin" /> : t('social.loadMore')}
</button>
</li>
)}
</ul>
)}
</Sheet>
)
}
function Row({
n,
onOpenProfile,
onOpenItem,
onOpenComments,
onOpenSharedList,
}: {
n: AppNotification
onOpenProfile: (username: string) => void
onOpenItem: (itemId: string) => void
onOpenComments?: (itemId: string, title: string) => void
onOpenSharedList?: (listId: string) => void
}) {
const unread = n.read_at === null
const isEpisode = EPISODE_KINDS.includes(n.kind)
const base = cx('flex items-center gap-3 border-b border-line px-4 py-3 text-start', unread && 'bg-surface-2')
// ── Nouvel épisode / nouvelle saison ──
if (isEpisode) {
const title = n.title ?? '—'
const inner = (
<>
{unread && <span className="size-2 shrink-0 rounded-full bg-accent-fill" aria-hidden="true" />}
<span className="grid size-[38px] shrink-0 place-items-center rounded-full bg-surface-2 text-accent">
<Tv size={18} />
</span>
<span className="min-w-0 flex-1 text-sm leading-snug text-ink-2">
<b className="text-ink">{t(n.kind === 'new_season' ? 'notif.new_season' : 'notif.new_episode', { title })}</b>
{n.episode != null && <span className="text-ink-3"> · {t('episodes.short', { n: n.episode })}</span>}
</span>
<span className="shrink-0 text-xs text-ink-3">{formatDate(n.created_at)}</span>
</>
)
return (
<li>
{n.item_id ? (
<button onClick={() => onOpenItem(n.item_id!)} className={cx(base, 'w-full')}>
{inner}
</button>
) : (
<div className={base}>{inner}</div>
)}
</li>
)
}
// ── Commentaire sur mon avis / invitation à une liste partagée ──
if (n.kind === 'review_comment' || n.kind === 'shared_list_invite') {
return <SocialRow n={n} base={base} unread={unread} onOpenProfile={onOpenProfile} onOpenComments={onOpenComments} onOpenSharedList={onOpenSharedList} />
}
// ── Abonnements / réactions ──
const actor = n.actor
const actorName = actor?.display_name ?? t('notif.someone')
const username = actor?.username
const target = username != null && FOLLOW_KINDS.includes(n.kind) ? username : null
const inner = (
<>
{unread && <span className="size-2 shrink-0 rounded-full bg-accent-fill" aria-hidden="true" />}
<Avatar url={actor?.avatar_url ?? undefined} name={actorName} size={38} />
<span className="min-w-0 flex-1 text-sm leading-snug text-ink-2">
<b className="text-ink">{actorName}</b> {VERB[n.kind]()}
{n.kind === 'reaction' && (
<>
{n.emoji ? ` ${n.emoji}` : ''}
{n.title ? ` ${t('notif.on', { title: n.title })}` : ''}
</>
)}
</span>
<span className="shrink-0 text-xs text-ink-3">{formatDate(n.created_at)}</span>
</>
)
return (
<li>
{target != null ? (
<button onClick={() => onOpenProfile(target)} className={cx(base, 'w-full')}>
{inner}
</button>
) : (
<div className={base}>{inner}</div>
)}
</li>
)
}
function SocialRow({
n,
base,
unread,
onOpenProfile,
onOpenComments,
onOpenSharedList,
}: {
n: AppNotification
base: string
unread: boolean
onOpenProfile: (username: string) => void
onOpenComments?: (itemId: string, title: string) => void
onOpenSharedList?: (listId: string) => void
}) {
const social = useSocial()
const [status, setStatus] = useState(n.invite_status)
const [busy, setBusy] = useState(false)
const actor = n.actor
const actorName = actor?.display_name ?? t('notif.someone')
const isInvite = n.kind === 'shared_list_invite'
const respond = async (accept: boolean) => {
if (!n.item_id) return
setBusy(true)
try {
await respondToInvite(n.item_id, accept)
setStatus(accept ? 'accepted' : null)
social.bumpShared()
if (accept) onOpenSharedList?.(n.item_id)
} catch {
/* invitation expirée ou réseau : rien ne change */
} finally {
setBusy(false)
}
}
// Où mène un tap sur la ligne
const open =
!isInvite && n.item_id && onOpenComments
? () => onOpenComments(n.item_id!, n.title ?? '')
: isInvite && status === 'accepted' && n.item_id && onOpenSharedList
? () => onOpenSharedList(n.item_id!)
: null
const text = (
<span className="min-w-0 flex-1 text-sm leading-snug text-ink-2">
<b className="text-ink">{actorName}</b> {VERB[n.kind]()}
{isInvite ? (
n.title ? (
<>
{' '}
<b className="text-ink">{n.title}</b>
</>
) : (
` (${t('shared.expired')})`
)
) : n.title ? (
` ${t('notif.on', { title: n.title })}`
) : (
''
)}
</span>
)
return (
<li>
<div className={cx(base, 'flex-wrap')}>
{unread && <span className="size-2 shrink-0 rounded-full bg-accent-fill" aria-hidden="true" />}
<button type="button" onClick={() => actor && onOpenProfile(actor.username)} className="shrink-0" aria-label={actorName} disabled={!actor}>
<Avatar url={actor?.avatar_url ?? undefined} name={actorName} size={38} />
</button>
{open ? (
<button type="button" onClick={open} className="flex min-w-0 flex-1 items-center gap-2 text-start">
{isInvite ? <Users size={14} className="shrink-0 text-accent" aria-hidden="true" /> : <MessageCircle size={14} className="shrink-0 text-accent" aria-hidden="true" />}
{text}
</button>
) : (
text
)}
<span className="shrink-0 text-xs text-ink-3">{formatDate(n.created_at)}</span>
{isInvite && status === 'pending' && n.title && (
<div className="flex w-full justify-end gap-2 ps-[3.25rem]">
<button type="button" onClick={() => void respond(false)} disabled={busy} className="btn btn-ghost px-3.5 py-1.5 text-sm">
{t('shared.decline')}
</button>
<button type="button" onClick={() => void respond(true)} disabled={busy} className="btn btn-primary px-3.5 py-1.5 text-sm">
{busy ? <Loader2 size={14} className="animate-spin" /> : <Check size={14} />} {t('shared.accept')}
</button>
</div>
)}
</div>
</li>
)
}
+3 -42
View File
@@ -1,6 +1,5 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
import { getFollowRequests, getMyProfile, type Profile, type ProfileCard } from '../../lib/cloud/social'
import { unreadCount } from '../../lib/cloud/notifications'
import { useMedia } from '../../store'
import type { MediaItem } from '../../types'
import EditProfile from './EditProfile'
@@ -9,7 +8,6 @@ import ItemPeek, { type PeekOwner } from './ItemPeek'
import PeopleSearch from './PeopleSearch'
import ProfileView from './ProfileView'
import TitleReviews from './TitleReviews'
import Notifications from './Notifications'
import { useOnResume } from '../../lib/onResume'
import WelcomeProfile, { RANDOM_USERNAME } from './WelcomeProfile'
import CommentsSheet from './CommentsSheet'
@@ -30,10 +28,6 @@ interface SocialApi {
openFollowList: (profile: Profile, kind: 'followers' | 'following') => void
/** Tous les avis sur un titre (amis / autres) */
openReviews: (externalId: string, title: string) => void
/** Panneau des notifications */
openNotifications: () => void
/** Notifications non lues */
unread: number
peek: (item: MediaItem, owner?: PeekOwner) => void
/** Ouvre la fiche si elle est à moi, sinon l'aperçu */
openItem: (item: MediaItem, owner?: PeekOwner) => void
@@ -60,8 +54,6 @@ const SocialContext = createContext<SocialApi>({
openEdit: () => {},
openFollowList: () => {},
openReviews: () => {},
openNotifications: () => {},
unread: 0,
peek: () => {},
openItem: () => {},
openComments: () => {},
@@ -80,7 +72,6 @@ type Overlay =
| { kind: 'edit' }
| { kind: 'follows'; profile: Profile; list: 'followers' | 'following' }
| { kind: 'reviews'; externalId: string; title: string }
| { kind: 'notifications' }
| { kind: 'comments'; authorId: string; itemId: string; title: string }
| { kind: 'sharedList'; id: string }
| { kind: 'invite'; listId: string; listName: string }
@@ -100,7 +91,6 @@ export function SocialProvider({
const enabled = !!account
const [me, setMe] = useState<Profile | null>(null)
const [requests, setRequests] = useState<ProfileCard[]>([])
const [unread, setUnread] = useState(0)
const [stack, setStack] = useState<Overlay[]>([])
const [peeked, setPeeked] = useState<{ item: MediaItem; owner?: PeekOwner }>()
const [sharedTick, setSharedTick] = useState(0)
@@ -125,10 +115,9 @@ export function SocialProvider({
const refresh = useCallback(async () => {
if (!enabled || !navigator.onLine) return
try {
const [p, r, u] = await Promise.all([getMyProfile(), getFollowRequests(), unreadCount()])
const [p, r] = await Promise.all([getMyProfile(), getFollowRequests()])
setMe(p)
setRequests(r)
setUnread(u)
} catch {
/* hors-ligne / serveur pas encore à jour : le reste de l'app fonctionne */
}
@@ -202,12 +191,6 @@ export function SocialProvider({
openEdit: () => push({ kind: 'edit' }),
openFollowList: (profile, list) => push({ kind: 'follows', profile, list }),
openReviews: (externalId, title) => push({ kind: 'reviews', externalId, title }),
openNotifications: () => {
// La liste se marque lue elle-même, après chargement (sinon les « non lu » n'étaient jamais visibles)
setUnread(0)
push({ kind: 'notifications' })
},
unread,
peek: (item, owner) => setPeeked({ item, owner }),
openItem,
openComments: (authorId, itemId, title) => push({ kind: 'comments', authorId, itemId, title }),
@@ -217,7 +200,7 @@ export function SocialProvider({
sharedTick,
bumpShared,
}),
[enabled, me, requests, unread, refresh, push, openItem, openTitle, sharedTick, bumpShared],
[enabled, me, requests, refresh, push, openItem, openTitle, sharedTick, bumpShared],
)
return (
@@ -239,30 +222,8 @@ export function SocialProvider({
<CommentsSheet key={k} authorId={o.authorId} itemId={o.itemId} title={o.title} onClose={pop} />
) : o.kind === 'sharedList' ? (
<SharedListSheet key={k} id={o.id} onClose={pop} />
) : o.kind === 'invite' ? (
<InvitePeople key={k} listId={o.listId} listName={o.listName} onClose={pop} />
) : (
<Notifications
key={k}
onClose={pop}
onOpenProfile={(u) => push({ kind: 'profile', username: u })}
onOpenItem={(id) => {
const it = items.find((i) => i.id === id)
if (it) {
pop()
onOpenOwnItem(it)
}
}}
onOpenComments={(itemId, title) => {
if (!me) return
pop()
push({ kind: 'comments', authorId: me.id, itemId, title })
}}
onOpenSharedList={(id) => {
pop()
push({ kind: 'sharedList', id })
}}
/>
<InvitePeople key={k} listId={o.listId} listName={o.listName} onClose={pop} />
),
)}
{children}