correction bug
deploy / deploy (push) Successful in 31s

This commit is contained in:
Romain committed 2026-10-04 13:38:33 +02:00
1 parent eaad6f1e77
commit a5da756803
51 files changed
+537 -672

No files matched your search

+16 -2
View File
@@ -1,5 +1,5 @@
import { Camera, ImagePlus, Loader2, Lock, Trash2 } from 'lucide-react'
import { useRef, useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../../i18n'
import { deleteProfileImage, updateProfile, uploadProfileImage, USERNAME_RE, type ProfilePatch } from '../../lib/cloud/social'
import { cropImageToJpeg } from '../../lib/image'
@@ -22,6 +22,20 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
const avatarInput = useRef<HTMLInputElement>(null)
const bannerInput = useRef<HTMLInputElement>(null)
// Aperçus locaux : libérés dès qu'ils sont remplacés ou que la fenêtre se ferme
useEffect(() => {
const url = avatar.preview
return () => {
if (url?.startsWith('blob:')) URL.revokeObjectURL(url)
}
}, [avatar.preview])
useEffect(() => {
const url = banner.preview
return () => {
if (url?.startsWith('blob:')) URL.revokeObjectURL(url)
}
}, [banner.preview])
const cleanUsername = username.trim().toLowerCase().replace(/^@/, '')
const usernameOk = USERNAME_RE.test(cleanUsername)
const nameOk = displayName.trim().length >= 1 && displayName.trim().length <= 40
@@ -152,7 +166,7 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
<span className="mt-1 block text-right text-[11px] text-ink-3">{bio.length}/300</span>
</label>
<button type="button" onClick={() => setIsPrivate((v) => !v)} className="flex w-full items-center gap-3 rounded-2xl border border-line px-4 py-3.5 text-left">
<button type="button" role="switch" aria-checked={isPrivate} onClick={() => setIsPrivate((v) => !v)} className="flex w-full items-center gap-3 rounded-2xl border border-line px-4 py-3.5 text-left">
<Lock size={18} className="shrink-0 text-ink-2" />
<span className="flex-1">
<span className="block text-sm font-medium">{t('social.privateAccount')}</span>
+3 -1
View File
@@ -13,7 +13,9 @@ type Tab = 'followers' | 'following' | 'requests'
export default function FollowList({ profile, initial, onClose }: { profile: Profile; initial: 'followers' | 'following'; onClose: () => void }) {
const social = useSocial()
const showRequests = profile.isMe && social.requests.length > 0
const [tab, setTab] = useState<Tab>(showRequests && initial === 'followers' ? 'requests' : initial)
const [picked, setTab] = useState<Tab>(showRequests && initial === 'followers' ? 'requests' : initial)
// Dernière demande acceptée : l'onglet « Demandes » disparaît, on retombe sur les abonnés
const tab: Tab = picked === 'requests' && !showRequests ? 'followers' : picked
const [list, setList] = useState<ProfileCard[]>()
const [busy, setBusy] = useState<string>()
+5 -6
View File
@@ -1,5 +1,5 @@
import { Check, Loader2, Plus, Star } from 'lucide-react'
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { t } from '../../i18n'
import { genreLabel } from '../../lib/genres'
import { useScrollLock } from '../../lib/scrollLock'
@@ -9,6 +9,7 @@ import type { MediaInput, MediaItem } from '../../types'
import { StatusPill, TypeBadge } from '../Badges'
import Poster from '../Poster'
import Avatar from './Avatar'
import { useEscape } from '../../lib/escape'
export interface PeekOwner {
username: string
@@ -27,11 +28,7 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
useScrollLock()
useEffect(() => {
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
useEscape(onClose)
const addToWatchlist = async () => {
setBusy(true)
@@ -46,11 +43,13 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
criteria: {},
episodesWatched: 0,
episodesTotal: item.episodesTotal,
seasons: item.seasons,
episodeDuration: item.episodeDuration,
duration: item.duration,
genres: item.genres,
platform: item.platform,
poster: item.poster,
backdrop: item.backdrop,
overview: item.overview,
externalId: item.externalId,
countries: item.countries,
+4 -1
View File
@@ -16,7 +16,10 @@ export default function PeopleSearch({ onClose }: { onClose: () => void }) {
useEffect(() => {
const term = q.trim()
if (term.length < 2) return setResults([])
if (term.length < 2) {
setLoading(false)
return setResults([])
}
let alive = true
setLoading(true)
const timer = setTimeout(() => {
+18 -7
View File
@@ -1,6 +1,6 @@
import { Check, Loader2, Lock, Share2, Star, UserPlus } from 'lucide-react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { t } from '../../i18n'
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 { STATUSES, TOP_CATEGORIES } from '../../lib/constants'
import { cx, formatRating } from '../../lib/utils'
@@ -35,7 +35,7 @@ function PosterTile({ item, onOpen, caption }: { item: MediaItem; onOpen: () =>
function Stat({ value, label, onClick }: { value?: number; label: string; onClick?: () => void }) {
const body = (
<>
<span className="block text-lg font-bold tabular-nums leading-tight">{value == null ? '—' : value.toLocaleString()}</span>
<span className="block text-lg font-bold tabular-nums leading-tight">{value == null ? '—' : fmtNumber(value)}</span>
<span className="block text-[11px] text-ink-3">{label}</span>
</>
)
@@ -51,6 +51,7 @@ function Stat({ value, label, onClick }: { value?: number; label: string; onClic
/** Page de profil (la mienne ou celle d'un autre). */
export default function ProfileView({ username, onClose }: { username: string; onClose: () => void }) {
const social = useSocial()
const { settings } = useMedia()
const [profile, setProfile] = useState<Profile | null>()
const [error, setError] = useState<string>()
const [tab, setTab] = useState<'profile' | 'library'>('profile')
@@ -133,12 +134,14 @@ export default function ProfileView({ username, onClose }: { username: string; o
const topByCategory = useMemo(() => {
const out: { label: string; items: MediaItem[] }[] = []
for (const c of TOP_CATEGORIES) {
// Mon profil : mes réglages locaux font foi tout de suite (même avant la synchro)
const shown = profile?.isMe ? TOP_CATEGORIES.filter((c) => settings.topCategories.includes(c.value)) : TOP_CATEGORIES
for (const c of shown) {
const list = (profile?.top ?? []).filter((i) => i.top?.category === c.value).sort((a, b) => a.top!.rank - b.top!.rank)
if (list.length) out.push({ label: c.plural, items: list })
}
return out
}, [profile])
}, [profile, settings.topCategories])
return (
<Sheet
@@ -335,7 +338,7 @@ function ProfileTab({ profile, topByCategory, onOpen }: { profile: Profile; topB
].map(([v, label]) => (
<div key={label as string} className="card p-4">
<div className="eyebrow">{label}</div>
<div className="mt-2 text-2xl font-bold tabular-nums leading-none">{(v as number).toLocaleString()}</div>
<div className="mt-2 text-2xl font-bold tabular-nums leading-none">{fmtNumber(v as number)}</div>
</div>
))}
</div>
@@ -351,15 +354,23 @@ function LibraryTab({ profile, onOpen }: { profile: Profile; onOpen: (i: MediaIt
const [loading, setLoading] = useState(false)
const [done, setDone] = useState(false)
const request = 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([])
try {
const page = await getProfileItems(profile.id, status || null, reset ? 0 : list.length)
if (id !== request.current) return
setList((prev) => (reset ? page : [...prev, ...page]))
setDone(page.length < 48)
} catch {
if (id === request.current) setDone(true)
} finally {
setLoading(false)
if (id === request.current) setLoading(false)
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
+3 -6
View File
@@ -1,16 +1,13 @@
import { X } from 'lucide-react'
import { useEffect, type ReactNode } from 'react'
import { type ReactNode } from 'react'
import { t } from '../../i18n'
import { useScrollLock } from '../../lib/scrollLock'
import { useEscape } from '../../lib/escape'
/** Écran plein (profil, recherche…) avec en-tête et bouton fermer. */
export default function Sheet({ title, onClose, right, children, label }: { title: ReactNode; onClose: () => void; right?: ReactNode; children: ReactNode; label: string }) {
useScrollLock()
useEffect(() => {
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
useEscape(onClose)
return (
<div className="sheet-in fixed inset-0 z-50 flex flex-col bg-bg" role="dialog" aria-modal="true" aria-label={label}>
<header className="safe-top border-b border-line">