Notifications : réactions et commentaires sur mes avis, activité des comptes suivis
deploy / deploy (push) Successful in 39s

- Quelqu'un réagit (emoji) ou commente mon avis → notification avec le titre ; la toucher ouvre ma fiche
- Un compte que je suis donne son avis, commence une série / un anime / un drama, ou ajoute un titre
  à « À voir » → notification avec l'affiche ; la toucher ouvre sa fiche
- Serveur (migration 20261128180000, appliquée) : déclencheurs sur réactions, commentaires et fiches ;
  rafales (import, ajouts en série) regroupées en une seule notification par personne et par type sur 3 h ;
  jamais entre comptes bloqués ni d'un compte suspendu ; une réaction retirée retire sa notification
- Pas de notification pour les listes perso : elles sont privées
- Textes dans les 18 langues

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-28 09:39:28 +00:00
1 parent 2a4261219c
commit 3487e8c305
22 files changed
+322 -27

No files matched your search

+25 -4
View File
@@ -1,7 +1,8 @@
import { Loader2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t, type TKey } from '../../i18n'
import { acceptFollower, getNotifications, markNotificationsRead, removeFollower, type FollowNotification } from '../../lib/cloud/social'
import { acceptFollower, getNotifications, markNotificationsRead, MINE_ITEM_KINDS, removeFollower, type FollowNotification } from '../../lib/cloud/social'
import Poster from '../Poster'
import { timeAgo } from '../../lib/timeAgo'
import { cx } from '../../lib/utils'
import Avatar from './Avatar'
@@ -13,9 +14,17 @@ const TEXT: Record<FollowNotification['kind'], TKey> = {
follow_request: 'notif.followRequest',
unfollow: 'notif.unfollow',
follow_accepted: 'notif.followAccepted',
reaction: 'notif.reaction',
review_comment: 'notif.reviewComment',
friend_review: 'notif.friendReview',
friend_started: 'notif.friendStarted',
friend_added: 'notif.friendAdded',
}
/** Qui s'est abonné, désabonné, a demandé à s'abonner ou a accepté ma demande. Ouvrir la liste la marque comme lue. */
/**
* Abonnements (qui s'abonne, se désabonne, demande, accepte), réactions et commentaires sur mes avis,
* et activité des comptes que je suis (avis, série commencée, titre ajouté). Ouvrir la liste la marque comme lue.
*/
export default function NotificationsSheet({ onClose, onSeen }: { onClose: () => void; onSeen: () => void }) {
const social = useSocial()
const [list, setList] = useState<FollowNotification[]>()
@@ -38,6 +47,13 @@ export default function NotificationsSheet({ onClose, onSeen }: { onClose: () =>
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// Toucher une notification : le titre concerné s'il y en a un (le mien ou celui de la personne), sinon son profil
const open = (n: FollowNotification) => {
if (!n.item) return social.openProfile(n.actor.username)
if (MINE_ITEM_KINDS.includes(n.kind)) social.openItem(n.item)
else social.openItem(n.item, { username: n.actor.username, displayName: n.actor.displayName, avatarUrl: n.actor.avatarUrl })
}
const pending = new Set(social.requests.map((r) => r.id))
const answer = async (id: string, accept: boolean) => {
setBusy(id)
@@ -68,20 +84,25 @@ export default function NotificationsSheet({ onClose, onSeen }: { onClose: () =>
<ul className="divide-y divide-line">
{list.map((n) => (
<li key={n.id} className="flex items-center gap-3 py-3">
<button onClick={() => social.openProfile(n.actor.username)} className="flex min-w-0 flex-1 items-center gap-3 text-start">
<button onClick={() => open(n)} className="flex min-w-0 flex-1 items-center gap-3 text-start">
<span className="relative shrink-0">
<Avatar url={n.actor.avatarUrl} name={n.actor.displayName} size={44} />
{!n.read && <span className="absolute -end-0.5 -top-0.5 size-3 rounded-full border-2 border-bg bg-accent-fill" aria-hidden="true" />}
</span>
<span className="min-w-0 flex-1">
<span className={cx('block text-sm leading-snug', n.kind === 'unfollow' ? 'text-ink-2' : 'text-ink')}>
{t(TEXT[n.kind], { name: n.actor.displayName })}
{t(TEXT[n.kind], { name: n.actor.displayName, title: n.item?.title ?? '', emoji: n.emoji ?? '' })}
</span>
<span className="mt-0.5 flex gap-2 text-xs text-ink-3">
<span className="truncate">@{n.actor.username}</span>
<span className="shrink-0">{timeAgo(n.createdAt)}</span>
</span>
</span>
{n.item && (
<span className="w-10 shrink-0">
<Poster src={n.item.poster} title={n.item.title} />
</span>
)}
</button>
{n.kind === 'follow_request' && pending.has(n.actor.id) && (
<span className="flex shrink-0 gap-1.5">