Audit : corrections de bugs, sécurité et performances (sans changement de fonctionnement)
Données et synchro - Import « remplacer » atomique (plus de bibliothèque vidée si l'écriture échoue). - Deux onglets sur le même compte : mise à jour croisée, file d'envoi partagée sans perte. - Réception : une modification locale faite pendant la synchro n'est plus écrasée ; une seule transaction. - Envoi : file vidée paquet par paquet, fiche invalide isolée (quota : gardée en attente), taille en octets réels, délai proportionnel à la taille ; grandes affiches décodées sans fetch (bloqué par la CSP). - Plus d'écriture dans la base d'un autre compte après déconnexion ; base fermée proprement (iOS). - Revisionnages journalisés à part (rewatchLog) : les défis ne sous-estiment plus le 1er visionnage ; décocher des épisodes un autre jour ne gonfle plus les défis. Comptes et social - Renouvellement de session : plus de déconnexion de tous les onglets avec un jeton déjà utilisé, plus de rafale de renouvellements, déconnexion qui révoque bien la session serveur. - Délais maximum sur les appels réseau, écran blanc évité au retour de Google. - Abonnés/abonnements au-delà de 50, pagination du fil et des profils, fil hors-ligne, listes bloquées. - Code mort retiré (CommentsSheet et options jamais utilisées). Interface et logique - Toast qui ne disparaissait plus, focus sur « Annuler » dans les confirmations, Échap pendant la saisie IME. - Demi-étoile en arabe, flèches RTL, fonds d'overlay en jeton de thème, couleur du thème étoilé. - Séries en cours sans total connu : les nouveaux épisodes se cochent à nouveau ; épisodes spéciaux ignorés. - Catalogue, accueil et calendrier plus rapides sur les grosses bibliothèques. Sources externes - Proxy TMDB : les 18 langues acceptées (9 étaient refusées), 429 transmis, délais, paramètres durcis. - Contenus adultes AniList filtrés des recommandations, cache d'import borné, imports plus sûrs. Serveur (migration 20261122140000_audit_hardening.sql, déjà appliquée en ligne) - Fonctions admin et « comptes suspendus » versionnées ; blocage effectif ; avis robustes ; fiches supprimées vidées ; comptes suspendus sans abonnement ni réaction ; objets morts supprimés. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
73 files changed
+2074
-2162
No files matched your search
@@ -1,26 +0,0 @@
|
||||
import { t } from '../../i18n'
|
||||
import { useMedia } from '../../store'
|
||||
import ReviewComments from './ReviewComments'
|
||||
import ReviewText from './ReviewText'
|
||||
import Sheet from './Sheet'
|
||||
|
||||
/** Commentaires sous un de mes avis, en plein écran (ouvert depuis une notification). */
|
||||
export default function CommentsSheet({ authorId, itemId, title, onClose }: { authorId: string; itemId: string; title: string; onClose: () => void }) {
|
||||
const { items } = useMedia()
|
||||
// Mon avis tel qu'il est sur cet appareil (les commentaires viennent du serveur)
|
||||
const mine = items.find((i) => i.id === itemId)
|
||||
return (
|
||||
<Sheet title={title || t('comments.title')} label={t('comments.title')} onClose={onClose} elevated>
|
||||
<div className="px-4 pt-4">
|
||||
{mine?.notes && (
|
||||
<article className="card mb-4 p-3.5">
|
||||
<p className="eyebrow">{t('form.review')}</p>
|
||||
<ReviewText text={mine.notes} spoiler={mine.notesSpoiler} revealed clamp />
|
||||
</article>
|
||||
)}
|
||||
<p className="eyebrow mb-1">{t('comments.title')}</p>
|
||||
<ReviewComments authorId={authorId} itemId={itemId} defaultOpen />
|
||||
</div>
|
||||
</Sheet>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { acceptFollower, getFollowList, removeFollower, type Profile, type ProfileCard } from '../../lib/cloud/social'
|
||||
import { acceptFollower, FOLLOW_PAGE, getFollowList, removeFollower, type Profile, type ProfileCard } from '../../lib/cloud/social'
|
||||
import { cx } from '../../lib/utils'
|
||||
import { GuestError } from '../../store'
|
||||
import { useToast } from '../Toast'
|
||||
import PersonRow from './PersonRow'
|
||||
import Sheet from './Sheet'
|
||||
import { useSocial } from './SocialProvider'
|
||||
@@ -18,19 +20,53 @@ export default function FollowList({ profile, initial, onClose }: { profile: Pro
|
||||
const tab: Tab = picked === 'requests' && !showRequests ? 'followers' : picked
|
||||
const [list, setList] = useState<ProfileCard[]>()
|
||||
const [busy, setBusy] = useState<string>()
|
||||
const toast = useToast()
|
||||
// Le serveur renvoie les comptes par pages : lignes reçues (décalage de la suivante) et page suivante possible
|
||||
const received = useRef(0)
|
||||
const [more, setMore] = useState(false)
|
||||
const [loadingMore, setLoadingMore] = useState(false)
|
||||
// Numéro du dernier chargement : une page arrivée après un changement d'onglet est ignorée
|
||||
const request = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
const id = ++request.current
|
||||
received.current = 0
|
||||
setMore(false)
|
||||
setLoadingMore(false)
|
||||
if (tab === 'requests') return setList(social.requests)
|
||||
let alive = true
|
||||
setList(undefined)
|
||||
getFollowList(profile.id, tab)
|
||||
.then((l) => alive && setList(l))
|
||||
.catch(() => alive && setList([]))
|
||||
return () => {
|
||||
alive = false
|
||||
}
|
||||
.then((page) => {
|
||||
if (id !== request.current) return
|
||||
received.current = page.received
|
||||
setList(page.cards)
|
||||
setMore(page.received >= FOLLOW_PAGE)
|
||||
})
|
||||
.catch(() => id === request.current && setList([]))
|
||||
}, [tab, profile.id, social.requests])
|
||||
|
||||
const loadMore = async () => {
|
||||
if (tab === 'requests' || loadingMore) return
|
||||
const id = request.current
|
||||
setLoadingMore(true)
|
||||
try {
|
||||
const page = await getFollowList(profile.id, tab, received.current)
|
||||
if (id !== request.current) return
|
||||
received.current += page.received
|
||||
// Sans doublon (même clé React) si la liste a bougé entre deux pages
|
||||
setList((l) => {
|
||||
const base = l ?? []
|
||||
const seen = new Set(base.map((p) => p.id))
|
||||
return [...base, ...page.cards.filter((p) => !seen.has(p.id) && !!seen.add(p.id))]
|
||||
})
|
||||
setMore(page.received >= FOLLOW_PAGE)
|
||||
} catch (e) {
|
||||
if (id === request.current) toast.show((e as Error).message)
|
||||
} finally {
|
||||
if (id === request.current) setLoadingMore(false)
|
||||
}
|
||||
}
|
||||
|
||||
const act = async (person: ProfileCard, action: 'accept' | 'remove') => {
|
||||
setBusy(person.id)
|
||||
try {
|
||||
@@ -38,6 +74,8 @@ export default function FollowList({ profile, initial, onClose }: { profile: Pro
|
||||
else await removeFollower(person.id)
|
||||
setList((l) => l?.filter((p) => p.id !== person.id))
|
||||
await social.refresh()
|
||||
} catch (e) {
|
||||
if (!(e instanceof GuestError)) toast.show((e as Error).message)
|
||||
} finally {
|
||||
setBusy(undefined)
|
||||
}
|
||||
@@ -92,6 +130,11 @@ export default function FollowList({ profile, initial, onClose }: { profile: Pro
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{list !== undefined && list.length > 0 && more && tab !== 'requests' && (
|
||||
<button onClick={() => void loadMore()} disabled={loadingMore} className="btn btn-ghost mt-3 w-full">
|
||||
{loadingMore ? <Loader2 size={16} className="animate-spin" /> : t('social.loadMore')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</Sheet>
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Loader2, Star, UserPlus } from 'lucide-react'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { getFeed, type FeedEntry } from '../../lib/cloud/social'
|
||||
import { FEED_PAGE, getFeed, type FeedEntry } from '../../lib/cloud/social'
|
||||
import { useOnResume } from '../../lib/onResume'
|
||||
import { timeAgo } from '../../lib/timeAgo'
|
||||
import { formatRating } from '../../lib/utils'
|
||||
@@ -11,6 +11,20 @@ import { LinkArrow, SectionTitle } from '../ui'
|
||||
import Avatar from './Avatar'
|
||||
import { useSocial } from './SocialProvider'
|
||||
|
||||
const feedKey = (e: FeedEntry) => `${e.id}-${e.createdAt}`
|
||||
|
||||
/** Ajoute une page sans doublon (même entrée reçue deux fois = même clé React). */
|
||||
function append(list: FeedEntry[], page: FeedEntry[]): FeedEntry[] {
|
||||
const seen = new Set(list.map(feedKey))
|
||||
const out = [...list]
|
||||
for (const e of page) {
|
||||
if (seen.has(feedKey(e))) continue
|
||||
seen.add(feedKey(e))
|
||||
out.push(e)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const VERB = { finished: 'feed.finished', started: 'feed.started', rewatched: 'feed.rewatched', added: 'feed.added' } as const
|
||||
|
||||
/** Accueil : ce que regardent mes abonnements. */
|
||||
@@ -21,20 +35,46 @@ export default function FriendsFeed() {
|
||||
const [more, setMore] = useState(false)
|
||||
const [loadingMore, setLoadingMore] = useState(false)
|
||||
const [shown, setShown] = useState(6)
|
||||
// Hors-ligne avant le premier chargement : message au lieu d'un chargement sans fin
|
||||
const [offline, setOffline] = useState(false)
|
||||
// Date de la dernière ligne reçue : point de départ de la page suivante
|
||||
const cursor = useRef<string | undefined>(undefined)
|
||||
// Numéro du dernier chargement : une réponse arrivée après un plus récent est ignorée
|
||||
const req = useRef(0)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
const id = ++req.current
|
||||
setLoadingMore(false)
|
||||
try {
|
||||
const list = await getFeed()
|
||||
setEntries(list)
|
||||
setMore(list.length >= 30)
|
||||
const page = await getFeed()
|
||||
if (id !== req.current) return
|
||||
cursor.current = page.cursor
|
||||
setEntries(append([], page.entries))
|
||||
setMore(page.received >= FEED_PAGE)
|
||||
setOffline(false)
|
||||
} catch {
|
||||
if (id !== req.current) return
|
||||
// Hors-ligne : on garde ce qui est déjà affiché
|
||||
if (!navigator.onLine) {
|
||||
setOffline(true)
|
||||
return
|
||||
}
|
||||
setEntries([])
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (social.enabled && navigator.onLine) void load()
|
||||
if (!social.enabled) return
|
||||
if (navigator.onLine) void load()
|
||||
else setOffline(true)
|
||||
}, [social.enabled, load])
|
||||
// Réseau retrouvé alors que le fil n'a jamais pu être chargé : on le charge
|
||||
useEffect(() => {
|
||||
if (!social.enabled || !offline) return
|
||||
const on = () => void load()
|
||||
window.addEventListener('online', on)
|
||||
return () => window.removeEventListener('online', on)
|
||||
}, [social.enabled, offline, load])
|
||||
// Retour sur l'app : on récupère ce que les abonnements ont ajouté entre-temps
|
||||
useOnResume(() => void load(), social.enabled)
|
||||
// Abonnement / désabonnement : le fil change aussi
|
||||
@@ -46,23 +86,30 @@ export default function FriendsFeed() {
|
||||
if (!social.enabled) return null
|
||||
|
||||
const loadMore = async () => {
|
||||
if (!entries) return
|
||||
if (!entries || loadingMore) return
|
||||
if (shown < entries.length) return setShown((n) => n + 10)
|
||||
const id = req.current
|
||||
setLoadingMore(true)
|
||||
try {
|
||||
const next = await getFeed(entries[entries.length - 1]?.createdAt)
|
||||
setEntries([...entries, ...next])
|
||||
setMore(next.length >= 30)
|
||||
const page = await getFeed(cursor.current ?? entries[entries.length - 1]?.createdAt)
|
||||
if (id !== req.current) return
|
||||
cursor.current = page.cursor ?? cursor.current
|
||||
setEntries((list) => append(list ?? [], page.entries))
|
||||
setMore(page.received >= FEED_PAGE)
|
||||
setShown((n) => n + 10)
|
||||
} catch {
|
||||
/* hors-ligne / serveur indisponible : le bouton reste là pour réessayer */
|
||||
} finally {
|
||||
setLoadingMore(false)
|
||||
if (id === req.current) setLoadingMore(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<SectionTitle action={<LinkArrow onClick={social.openSearch}>{t('social.findFriends')}</LinkArrow>}>{t('feed.title')}</SectionTitle>
|
||||
{entries === undefined ? (
|
||||
{entries === undefined && offline ? (
|
||||
<p className="text-sm text-ink-3">{t('common.offline')}</p>
|
||||
) : entries === undefined ? (
|
||||
<p className="flex items-center gap-2 text-sm text-ink-3">
|
||||
<Loader2 size={14} className="animate-spin" /> {t('social.loading')}
|
||||
</p>
|
||||
@@ -77,7 +124,7 @@ export default function FriendsFeed() {
|
||||
<>
|
||||
<ul className="divide-y divide-line">
|
||||
{entries.slice(0, shown).map((e) => (
|
||||
<li key={`${e.id}-${e.createdAt}`} className="flex items-center gap-3 py-2.5">
|
||||
<li key={feedKey(e)} className="flex items-center gap-3 py-2.5">
|
||||
<button onClick={() => social.openProfile(e.user.username)} aria-label={e.user.displayName}>
|
||||
<Avatar url={e.user.avatarUrl} name={e.user.displayName} size={36} />
|
||||
</button>
|
||||
|
||||
@@ -7,7 +7,8 @@ import { useScrollLock } from '../../lib/scrollLock'
|
||||
import { titleReviews, type TitleReview } from '../../lib/cloud/reviews'
|
||||
import { useSocial } from './SocialProvider'
|
||||
import { cx, formatDate, formatRating, normalizeText } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
import { GuestError, useMedia } from '../../store'
|
||||
import { useToast } from '../Toast'
|
||||
import type { MediaInput, MediaItem } from '../../types'
|
||||
import { StatusPill, TypeBadge } from '../Badges'
|
||||
import Poster from '../Poster'
|
||||
@@ -30,6 +31,7 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
|
||||
const social = useSocial()
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [added, setAdded] = useState(false)
|
||||
const toast = useToast()
|
||||
// Avis d'un autre membre : on récupère les réactions pour pouvoir réagir ici même
|
||||
const [review, setReview] = useState<TitleReview>()
|
||||
const canReact = !!owner && owner.username !== social.me?.username && !!item.notes && !!item.externalId
|
||||
@@ -83,13 +85,16 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
|
||||
}
|
||||
await add(input)
|
||||
setAdded(true)
|
||||
} catch (e) {
|
||||
// Mode découverte : l'invitation à créer un compte est déjà affichée
|
||||
if (!(e instanceof GuestError)) toast.show((e as Error).message)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-[60] flex touch-none items-end justify-center overscroll-none bg-black/70 sm:items-center sm:p-4" onClick={onClose}>
|
||||
<div className="fixed inset-0 z-[60] flex touch-none items-end justify-center overscroll-none bg-scrim sm:items-center sm:p-4" onClick={onClose}>
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Ban, Check, Loader2, Lock, Share2, Star, UserCheck, UserPlus } from 'lucide-react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { fmtNumber, t } from '../../i18n'
|
||||
import { follow, getProfile, getProfileItems, profileLink, unfollow, type Profile } from '../../lib/cloud/social'
|
||||
import { follow, getProfile, getProfileItems, PROFILE_ITEMS_PAGE, profileLink, unfollow, type Profile } from '../../lib/cloud/social'
|
||||
import { STATUSES, TOP_CATEGORIES } from '../../lib/constants'
|
||||
import { cx, formatRating } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
@@ -64,15 +64,22 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
const { isBlocked } = useBlocked(!!profile && !profile.isMe)
|
||||
const blocked = !!profile && !profile.isMe && isBlocked(profile.id)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setError(undefined)
|
||||
try {
|
||||
setProfile(await getProfile(username))
|
||||
} catch (e) {
|
||||
setError((e as Error).message)
|
||||
setProfile(null)
|
||||
}
|
||||
}, [username])
|
||||
/** `reload` : rechargement après une action (s'abonner, bloquer…) — en cas d'échec, on garde le profil affiché. */
|
||||
const load = useCallback(
|
||||
async (reload = false) => {
|
||||
if (!reload) setError(undefined)
|
||||
try {
|
||||
const next = await getProfile(username)
|
||||
if (reload) setError(undefined)
|
||||
setProfile(next)
|
||||
} catch (e) {
|
||||
if (reload) return setToast((e as Error).message)
|
||||
setError((e as Error).message)
|
||||
setProfile(null)
|
||||
}
|
||||
},
|
||||
[username],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
void load()
|
||||
@@ -113,7 +120,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
setBusy(true)
|
||||
try {
|
||||
await follow(profile.id)
|
||||
await load()
|
||||
await load(true)
|
||||
void social.refresh()
|
||||
} catch (e) {
|
||||
setToast((e as Error).message)
|
||||
@@ -128,7 +135,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
setBusy(true)
|
||||
try {
|
||||
await unfollow(profile.id)
|
||||
await load()
|
||||
await load(true)
|
||||
void social.refresh()
|
||||
} catch (e) {
|
||||
setToast((e as Error).message)
|
||||
@@ -144,7 +151,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
setBusy(true)
|
||||
try {
|
||||
await blockUser({ id: profile.id, username: profile.username, displayName: profile.displayName, avatarUrl: profile.avatarUrl })
|
||||
await load()
|
||||
await load(true)
|
||||
void social.refresh()
|
||||
setToast(t('block.done', { name: profile.displayName }))
|
||||
} catch (e) {
|
||||
@@ -422,18 +429,29 @@ function LibraryTab({ profile, onOpen }: { profile: Profile; onOpen: (i: MediaIt
|
||||
const [done, setDone] = useState(false)
|
||||
|
||||
const request = useRef(0)
|
||||
// Lignes reçues du serveur (y compris celles écartées à la relecture) : décalage de la page suivante
|
||||
const received = useRef(0)
|
||||
|
||||
const loadPage = useCallback(
|
||||
async (reset: boolean) => {
|
||||
// Une réponse arrivée après un changement de filtre ne doit pas écraser la nouvelle liste
|
||||
const id = ++request.current
|
||||
setLoading(true)
|
||||
if (reset) setList([])
|
||||
if (reset) {
|
||||
setList([])
|
||||
received.current = 0
|
||||
}
|
||||
try {
|
||||
const page = await getProfileItems(profile.id, status || null, reset ? 0 : list.length)
|
||||
const page = await getProfileItems(profile.id, status || null, reset ? 0 : received.current)
|
||||
if (id !== request.current) return
|
||||
setList((prev) => (reset ? page : [...prev, ...page]))
|
||||
setDone(page.length < 48)
|
||||
received.current += page.received
|
||||
setList((prev) => {
|
||||
// Sans doublon (une fiche ne peut apparaître qu'une fois : même clé React)
|
||||
const base = reset ? [] : prev
|
||||
const seen = new Set(base.map((i) => i.id))
|
||||
return [...base, ...page.items.filter((i) => !seen.has(i.id) && !!seen.add(i.id))]
|
||||
})
|
||||
setDone(page.received < PROFILE_ITEMS_PAGE)
|
||||
} catch {
|
||||
if (id === request.current) setDone(true)
|
||||
} finally {
|
||||
@@ -441,7 +459,7 @@ function LibraryTab({ profile, onOpen }: { profile: Profile; onOpen: (i: MediaIt
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[profile.id, status, list.length],
|
||||
[profile.id, status],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -17,7 +17,6 @@ export default function ReviewComments({
|
||||
authorId,
|
||||
itemId,
|
||||
count: initialCount,
|
||||
defaultOpen,
|
||||
hidden,
|
||||
children,
|
||||
}: {
|
||||
@@ -25,14 +24,13 @@ export default function ReviewComments({
|
||||
itemId: string
|
||||
/** Nombre connu (sinon chargé à l'ouverture) */
|
||||
count?: number | null
|
||||
defaultOpen?: boolean
|
||||
/** Serveur sans les commentaires (migration pas encore appliquée) : seules les autres actions s'affichent */
|
||||
hidden?: boolean
|
||||
children?: ReactNode
|
||||
}) {
|
||||
const social = useSocial()
|
||||
const { isBlocked } = useBlocked(social.enabled)
|
||||
const [open, setOpen] = useState(!!defaultOpen)
|
||||
const [open, setOpen] = useState(false)
|
||||
const [count, setCount] = useState(initialCount ?? undefined)
|
||||
const [comments, setComments] = useState<ReviewComment[]>()
|
||||
const [unavailable, setUnavailable] = useState(false)
|
||||
|
||||
@@ -11,17 +11,12 @@ export default function ReviewText({
|
||||
text,
|
||||
spoiler,
|
||||
className,
|
||||
clamp,
|
||||
revealed,
|
||||
}: {
|
||||
text: string
|
||||
spoiler?: boolean
|
||||
className?: string
|
||||
clamp?: boolean
|
||||
/** Déjà dévoilé (mon propre avis) : seul le badge « Spoiler » reste */
|
||||
revealed?: boolean
|
||||
}) {
|
||||
const [shown, setShown] = useState(!spoiler || !!revealed)
|
||||
const [shown, setShown] = useState(!spoiler)
|
||||
|
||||
if (!shown) {
|
||||
return (
|
||||
@@ -51,7 +46,7 @@ export default function ReviewText({
|
||||
<EyeOff size={11} aria-hidden="true" /> {t('spoiler.badge')}
|
||||
</span>
|
||||
)}
|
||||
<p className={cx('whitespace-pre-line break-words text-sm leading-relaxed text-ink-2', clamp && 'line-clamp-6')}>{text}</p>
|
||||
<p className="whitespace-pre-line break-words text-sm leading-relaxed text-ink-2">{text}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import ProfileView from './ProfileView'
|
||||
import TitleReviews from './TitleReviews'
|
||||
import { useOnResume } from '../../lib/onResume'
|
||||
import WelcomeProfile, { RANDOM_USERNAME } from './WelcomeProfile'
|
||||
import CommentsSheet from './CommentsSheet'
|
||||
import { InvitePeople, SharedListSheet } from './SharedLists'
|
||||
import { getAniListById, type SearchResult } from '../../lib/catalogApi'
|
||||
import { TYPE_BY_VALUE } from '../../lib/constants'
|
||||
@@ -28,11 +27,8 @@ interface SocialApi {
|
||||
openFollowList: (profile: Profile, kind: 'followers' | 'following') => void
|
||||
/** Tous les avis sur un titre (amis / autres) */
|
||||
openReviews: (externalId: string, title: string) => void
|
||||
peek: (item: MediaItem, owner?: PeekOwner) => void
|
||||
/** Ouvre la fiche si elle est à moi, sinon l'aperçu */
|
||||
openItem: (item: MediaItem, owner?: PeekOwner) => void
|
||||
/** Fil de commentaires d'un avis, en plein écran (depuis une notification) */
|
||||
openComments: (authorId: string, itemId: string, title: string) => void
|
||||
/** Liste partagée */
|
||||
openSharedList: (id: string) => void
|
||||
/** Inviter des membres dans une liste partagée */
|
||||
@@ -54,9 +50,7 @@ const SocialContext = createContext<SocialApi>({
|
||||
openEdit: () => {},
|
||||
openFollowList: () => {},
|
||||
openReviews: () => {},
|
||||
peek: () => {},
|
||||
openItem: () => {},
|
||||
openComments: () => {},
|
||||
openSharedList: () => {},
|
||||
openInvite: () => {},
|
||||
openTitle: () => {},
|
||||
@@ -66,13 +60,14 @@ const SocialContext = createContext<SocialApi>({
|
||||
|
||||
export const useSocial = () => useContext(SocialContext)
|
||||
|
||||
let overlayUid = 0
|
||||
|
||||
type Overlay =
|
||||
| { kind: 'profile'; username: string }
|
||||
| { kind: 'search' }
|
||||
| { kind: 'edit' }
|
||||
| { kind: 'follows'; profile: Profile; list: 'followers' | 'following' }
|
||||
| { kind: 'reviews'; externalId: string; title: string }
|
||||
| { kind: 'comments'; authorId: string; itemId: string; title: string }
|
||||
| { kind: 'sharedList'; id: string }
|
||||
| { kind: 'invite'; listId: string; listName: string }
|
||||
|
||||
@@ -91,7 +86,7 @@ export function SocialProvider({
|
||||
const enabled = !!account
|
||||
const [me, setMe] = useState<Profile | null>(null)
|
||||
const [requests, setRequests] = useState<ProfileCard[]>([])
|
||||
const [stack, setStack] = useState<Overlay[]>([])
|
||||
const [stack, setStack] = useState<(Overlay & { uid: number })[]>([])
|
||||
const [peeked, setPeeked] = useState<{ item: MediaItem; owner?: PeekOwner }>()
|
||||
const [sharedTick, setSharedTick] = useState(0)
|
||||
const bumpShared = useCallback(() => setSharedTick((n) => n + 1), [])
|
||||
@@ -129,8 +124,9 @@ export function SocialProvider({
|
||||
// Nouvelles demandes d'abonnement, compteurs… mis à jour au retour sur l'app
|
||||
useOnResume(() => void refresh(), enabled)
|
||||
|
||||
const push = useCallback((o: Overlay) => setStack((s) => [...s.slice(-8), o]), [])
|
||||
const pop = useCallback(() => setStack((s) => s.slice(0, -1)), [])
|
||||
// Clé stable par écran (et non sa place dans la pile, qui change quand la pile est écourtée)
|
||||
const push = useCallback((o: Overlay) => setStack((s) => [...s.slice(-8), { ...o, uid: ++overlayUid }]), [])
|
||||
const close = useCallback((uid: number) => setStack((s) => s.filter((x) => x.uid !== uid)), [])
|
||||
|
||||
// Lien partagé « #/u/pseudo »
|
||||
useEffect(() => {
|
||||
@@ -191,9 +187,7 @@ export function SocialProvider({
|
||||
openEdit: () => push({ kind: 'edit' }),
|
||||
openFollowList: (profile, list) => push({ kind: 'follows', profile, list }),
|
||||
openReviews: (externalId, title) => push({ kind: 'reviews', externalId, title }),
|
||||
peek: (item, owner) => setPeeked({ item, owner }),
|
||||
openItem,
|
||||
openComments: (authorId, itemId, title) => push({ kind: 'comments', authorId, itemId, title }),
|
||||
openSharedList: (id) => push({ kind: 'sharedList', id }),
|
||||
openInvite: (listId, listName) => push({ kind: 'invite', listId, listName }),
|
||||
openTitle: (s) => void openTitle(s),
|
||||
@@ -207,23 +201,21 @@ export function SocialProvider({
|
||||
<SocialContext.Provider value={api}>
|
||||
{/* Les écrans sociaux sont placés avant l'app : une fiche ouverte depuis un profil passe au-dessus */}
|
||||
{enabled &&
|
||||
stack.map((o, k) =>
|
||||
stack.map((o) =>
|
||||
o.kind === 'profile' ? (
|
||||
<ProfileView key={k} username={o.username} onClose={pop} />
|
||||
<ProfileView key={o.uid} username={o.username} onClose={() => close(o.uid)} />
|
||||
) : o.kind === 'search' ? (
|
||||
<PeopleSearch key={k} onClose={pop} />
|
||||
<PeopleSearch key={o.uid} onClose={() => close(o.uid)} />
|
||||
) : o.kind === 'edit' ? (
|
||||
<EditProfile key={k} onClose={pop} />
|
||||
<EditProfile key={o.uid} onClose={() => close(o.uid)} />
|
||||
) : o.kind === 'follows' ? (
|
||||
<FollowList key={k} profile={o.profile} initial={o.list} onClose={pop} />
|
||||
<FollowList key={o.uid} profile={o.profile} initial={o.list} onClose={() => close(o.uid)} />
|
||||
) : o.kind === 'reviews' ? (
|
||||
<TitleReviews key={k} externalId={o.externalId} title={o.title} onClose={pop} onOpenProfile={(u) => push({ kind: 'profile', username: u })} />
|
||||
) : o.kind === 'comments' ? (
|
||||
<CommentsSheet key={k} authorId={o.authorId} itemId={o.itemId} title={o.title} onClose={pop} />
|
||||
<TitleReviews key={o.uid} externalId={o.externalId} title={o.title} onClose={() => close(o.uid)} onOpenProfile={(u) => push({ kind: 'profile', username: u })} />
|
||||
) : o.kind === 'sharedList' ? (
|
||||
<SharedListSheet key={k} id={o.id} onClose={pop} />
|
||||
<SharedListSheet key={o.uid} id={o.id} onClose={() => close(o.uid)} />
|
||||
) : (
|
||||
<InvitePeople key={k} listId={o.listId} listName={o.listName} onClose={pop} />
|
||||
<InvitePeople key={o.uid} listId={o.listId} listName={o.listName} onClose={() => close(o.uid)} />
|
||||
),
|
||||
)}
|
||||
{children}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Loader2, Star } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { getSession } from '../../lib/cloud/auth'
|
||||
import { useBlocked } from '../../lib/cloud/moderation'
|
||||
import { titleReviews, type TitleReview, type TitleReviews as TitleReviewsData } from '../../lib/cloud/reviews'
|
||||
import { formatRating } from '../../lib/utils'
|
||||
@@ -71,6 +72,8 @@ function ReviewColumn({ heading, empty, list, onOpenProfile }: { heading: string
|
||||
|
||||
function ReviewCard({ r, onOpenProfile }: { r: TitleReview; onOpenProfile: (username: string) => void }) {
|
||||
const { settings } = useMedia()
|
||||
// Mon propre avis : ni signalement ni réaction (seuls les commentaires restent)
|
||||
const mine = r.user_id === getSession()?.user.id
|
||||
return (
|
||||
<article className="card p-3.5">
|
||||
<div className="flex items-center gap-2.5">
|
||||
@@ -85,12 +88,12 @@ function ReviewCard({ r, onOpenProfile }: { r: TitleReview; onOpenProfile: (user
|
||||
{formatRating(r.rating, settings.ratingScale)}
|
||||
</span>
|
||||
)}
|
||||
<ReportButton target={{ type: 'review', id: r.item_id, userId: r.user_id }} className="-me-1.5" size={16} />
|
||||
{!mine && <ReportButton target={{ type: 'review', id: r.item_id, userId: r.user_id }} className="-me-1.5" size={16} />}
|
||||
</div>
|
||||
{r.notes && <ReviewText text={r.notes} spoiler={r.spoiler} />}
|
||||
<div className="mt-3">
|
||||
<ReviewComments authorId={r.user_id} itemId={r.item_id} count={r.comments} hidden={r.comments === null}>
|
||||
<Reactions authorId={r.user_id} itemId={r.item_id} reactions={r.reactions} mine={r.mine} />
|
||||
{!mine && <Reactions authorId={r.user_id} itemId={r.item_id} reactions={r.reactions} mine={r.mine} />}
|
||||
</ReviewComments>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
Reference in new issue
Block a user