diff --git a/src/components/Roulette.tsx b/src/components/Roulette.tsx
index 17b7f3d..7d7a0d6 100644
--- a/src/components/Roulette.tsx
+++ b/src/components/Roulette.tsx
@@ -20,6 +20,7 @@ import type { MediaItem } from '../types'
import { TypeBadge } from './Badges'
import Poster from './Poster'
import { RatingBadge } from './Rating'
+import { useScrollLock } from '../lib/scrollLock'
const CARD = 112 // largeur d'une affiche dans le rouleau (w-28)
const GAP = 12
@@ -68,13 +69,7 @@ export default function Roulette({ onClose, onOpen }: Props) {
}
// Bloque le défilement derrière + mémorise les filtres
- useEffect(() => {
- const prev = document.body.style.overflow
- document.body.style.overflow = 'hidden'
- return () => {
- document.body.style.overflow = prev
- }
- }, [])
+ useScrollLock()
useEffect(() => saveFilters(filters), [filters])
// Changer les filtres efface le tirage en cours
diff --git a/src/components/TagInput.tsx b/src/components/TagInput.tsx
index c20b2fd..001f6a3 100644
--- a/src/components/TagInput.tsx
+++ b/src/components/TagInput.tsx
@@ -14,7 +14,7 @@ interface Props {
normalize?: (input: string) => string
}
-/** Saisie de tags libres avec suggestions tapables. */
+/** Saisie de tags libres ; des suggestions apparaissent quand on commence à taper. */
export default function TagInput({ value, onChange, suggestions, placeholder, display = (v) => v, normalize = (v) => v }: Props) {
const [text, setText] = useState('')
@@ -29,7 +29,9 @@ export default function TagInput({ value, onChange, suggestions, placeholder, di
const filtered = useMemo(() => {
const q = normalizeText(text)
const taken = new Set(value.map((v) => normalizeText(display(v))))
- return suggestions.filter((s) => !taken.has(normalizeText(s)) && (!q || normalizeText(s).includes(q))).slice(0, 12)
+ // Suggestions seulement pendant la saisie (pas de rangée de genres affichée en permanence)
+ if (!q) return []
+ return suggestions.filter((s) => !taken.has(normalizeText(s)) && normalizeText(s).includes(q)).slice(0, 12)
}, [text, value, suggestions])
return (
diff --git a/src/components/TopFiveEditor.tsx b/src/components/TopFiveEditor.tsx
index 42133fb..d98cb61 100644
--- a/src/components/TopFiveEditor.tsx
+++ b/src/components/TopFiveEditor.tsx
@@ -7,6 +7,7 @@ import { useMedia } from '../store'
import type { TopCategory } from '../types'
import { TypeBadge } from './Badges'
import Poster from './Poster'
+import { useScrollLock } from '../lib/scrollLock'
interface Props {
category: TopCategory
@@ -29,13 +30,7 @@ export default function TopFiveEditor({ category: initialCategory, onClose }: Pr
const catInfo = TOP_CATEGORIES.find((c) => c.value === category)!
const byId = useMemo(() => new Map(items.map((i) => [i.id, i])), [items])
- useEffect(() => {
- const prev = document.body.style.overflow
- document.body.style.overflow = 'hidden'
- return () => {
- document.body.style.overflow = prev
- }
- }, [])
+ useScrollLock()
/** Changer de catégorie enregistre d'abord celle en cours. */
const switchCategory = async (cat: TopCategory) => {
diff --git a/src/components/social/FriendsFeed.tsx b/src/components/social/FriendsFeed.tsx
index 9ad1e10..e9a5ff9 100644
--- a/src/components/social/FriendsFeed.tsx
+++ b/src/components/social/FriendsFeed.tsx
@@ -2,6 +2,7 @@ import { Loader2, Star, UserPlus } from 'lucide-react'
import { useCallback, useEffect, useState } from 'react'
import { t } from '../../i18n'
import { getFeed, type FeedEntry } from '../../lib/cloud/social'
+import { useOnResume } from '../../lib/onResume'
import { timeAgo } from '../../lib/timeAgo'
import { formatRating } from '../../lib/utils'
import { useMedia } from '../../store'
@@ -34,6 +35,13 @@ export default function FriendsFeed() {
useEffect(() => {
if (social.enabled && navigator.onLine) void load()
}, [social.enabled, 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
+ const followKey = `${social.me?.following ?? ''}`
+ useEffect(() => {
+ if (social.enabled && followKey && navigator.onLine) void load()
+ }, [followKey, social.enabled, load])
if (!social.enabled) return null
@@ -86,7 +94,7 @@ export default function FriendsFeed() {
{formatRating(e.item.rating, settings.ratingScale)}
)}
- {e.item.notes && e.item.notesPublic &&
{t('feed.review')}}
+ {e.item.notes &&
{t('feed.review')}}
{timeAgo(e.createdAt)}
diff --git a/src/components/social/ItemPeek.tsx b/src/components/social/ItemPeek.tsx
index 4a03e48..af55922 100644
--- a/src/components/social/ItemPeek.tsx
+++ b/src/components/social/ItemPeek.tsx
@@ -2,6 +2,7 @@ import { Check, Loader2, Plus, Star } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t } from '../../i18n'
import { genreLabel } from '../../lib/genres'
+import { useScrollLock } from '../../lib/scrollLock'
import { cx, formatDate, formatRating, normalizeText } from '../../lib/utils'
import { useMedia } from '../../store'
import type { MediaInput, MediaItem } from '../../types'
@@ -24,6 +25,8 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
(i) => (item.externalId && i.externalId === item.externalId) || normalizeText(i.title) === normalizeText(item.title),
)
+ useScrollLock()
+
useEffect(() => {
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
window.addEventListener('keydown', onKey)
@@ -61,12 +64,12 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
}
return (
-
+
e.stopPropagation()}
>
diff --git a/src/components/social/PersonRow.tsx b/src/components/social/PersonRow.tsx
index 4166c2b..045227b 100644
--- a/src/components/social/PersonRow.tsx
+++ b/src/components/social/PersonRow.tsx
@@ -21,6 +21,7 @@ export default function PersonRow({ person, actions }: { person: ProfileCard; ac
await unfollow(person.id)
setRelation('none')
}
+ void social.refresh()
} catch {
/* réseau : rien ne change */
} finally {
diff --git a/src/components/social/ProfileView.tsx b/src/components/social/ProfileView.tsx
index 2d1a179..0e73b14 100644
--- a/src/components/social/ProfileView.tsx
+++ b/src/components/social/ProfileView.tsx
@@ -108,6 +108,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
try {
await follow(profile.id)
await load()
+ void social.refresh()
} catch (e) {
setToast((e as Error).message)
} finally {
@@ -122,6 +123,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
try {
await unfollow(profile.id)
await load()
+ void social.refresh()
} catch (e) {
setToast((e as Error).message)
} finally {
diff --git a/src/components/social/Sheet.tsx b/src/components/social/Sheet.tsx
index 751e16b..5f1326c 100644
--- a/src/components/social/Sheet.tsx
+++ b/src/components/social/Sheet.tsx
@@ -1,18 +1,15 @@
import { X } from 'lucide-react'
import { useEffect, type ReactNode } from 'react'
import { t } from '../../i18n'
+import { useScrollLock } from '../../lib/scrollLock'
/** É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 prev = document.body.style.overflow
- document.body.style.overflow = 'hidden'
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
window.addEventListener('keydown', onKey)
- return () => {
- document.body.style.overflow = prev
- window.removeEventListener('keydown', onKey)
- }
+ return () => window.removeEventListener('keydown', onKey)
}, [onClose])
return (
diff --git a/src/components/social/SocialProvider.tsx b/src/components/social/SocialProvider.tsx
index 436287d..36ed528 100644
--- a/src/components/social/SocialProvider.tsx
+++ b/src/components/social/SocialProvider.tsx
@@ -7,6 +7,7 @@ import FollowList from './FollowList'
import ItemPeek, { type PeekOwner } from './ItemPeek'
import PeopleSearch from './PeopleSearch'
import ProfileView from './ProfileView'
+import { useOnResume } from '../../lib/onResume'
import WelcomeProfile, { RANDOM_USERNAME } from './WelcomeProfile'
interface SocialApi {
@@ -84,6 +85,8 @@ export function SocialProvider({ children, onOpenOwnItem }: { children: ReactNod
useEffect(() => {
void refresh()
}, [refresh])
+ // 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)), [])
diff --git a/src/lib/onResume.ts b/src/lib/onResume.ts
new file mode 100644
index 0000000..61b9078
--- /dev/null
+++ b/src/lib/onResume.ts
@@ -0,0 +1,28 @@
+import { useEffect, useRef } from 'react'
+
+/**
+ * Relance `fn` quand l'app revient au premier plan (onglet réaffiché, PWA rouverte, réseau retrouvé),
+ * au plus une fois toutes les `minGapMs`.
+ */
+export function useOnResume(fn: () => void, enabled = true, minGapMs = 20_000) {
+ const last = useRef(Date.now())
+ const cb = useRef(fn)
+ cb.current = fn
+ useEffect(() => {
+ if (!enabled) return
+ const run = () => {
+ if (document.visibilityState !== 'visible' || !navigator.onLine) return
+ if (Date.now() - last.current < minGapMs) return
+ last.current = Date.now()
+ cb.current()
+ }
+ document.addEventListener('visibilitychange', run)
+ window.addEventListener('focus', run)
+ window.addEventListener('online', run)
+ return () => {
+ document.removeEventListener('visibilitychange', run)
+ window.removeEventListener('focus', run)
+ window.removeEventListener('online', run)
+ }
+ }, [enabled, minGapMs])
+}
diff --git a/src/lib/scrollLock.ts b/src/lib/scrollLock.ts
new file mode 100644
index 0000000..c7b3385
--- /dev/null
+++ b/src/lib/scrollLock.ts
@@ -0,0 +1,23 @@
+import { useEffect } from 'react'
+
+/**
+ * Bloque le défilement de la page derrière une fenêtre (fiche, profil, aperçu…).
+ * Compteur partagé : avec plusieurs fenêtres empilées, la page ne se débloque qu'à la fermeture de la dernière.
+ */
+let locks = 0
+
+function apply(on: boolean) {
+ for (const el of [document.documentElement, document.body]) {
+ el.style.overflow = on ? 'hidden' : ''
+ el.style.overscrollBehavior = on ? 'none' : ''
+ }
+}
+
+export function useScrollLock() {
+ useEffect(() => {
+ if (locks++ === 0) apply(true)
+ return () => {
+ if (--locks === 0) apply(false)
+ }
+ }, [])
+}
diff --git a/supabase/migrations/20261002120000_social.sql b/supabase/migrations/20261002120000_social.sql
index e1e2015..b6880e0 100644
--- a/supabase/migrations/20261002120000_social.sql
+++ b/supabase/migrations/20261002120000_social.sql
@@ -344,7 +344,8 @@ immutable
set search_path = ''
as $$
select case when length(coalesce(x->>'poster', '')) > 150000 then x - 'poster' else x end
- from (select (case when d->>'notesPublic' = 'true' then d else d - 'notes' end) - 'listIds' as x) s
+ -- Les avis sont publics (comme sur Letterboxd) ; les listes perso restent privées
+ from (select d - 'listIds' - 'notesPublic' as x) s
$$;
create or replace function public.profile_card(p public.profiles)
@@ -409,9 +410,10 @@ begin
from public.items where user_id = p.id and not deleted and jsonb_typeof(data->'top') = 'object'
),
'recent', (
- select coalesce(jsonb_agg(public.public_item(s.data) order by s.k desc), '[]'::jsonb)
+ select coalesce(jsonb_agg(public.public_item(s.data) order by s.k desc nulls last), '[]'::jsonb)
from (
- select data, coalesce(data->>'endDate', left(data->>'updatedAt', 10)) as k
+ -- Date de visionnage (pas la date de modification : un import ou une synchro ne doit pas tout faire remonter)
+ select data, coalesce(data->>'endDate', data->>'startDate') as k
from public.items
where user_id = p.id and not deleted and data->>'status' = 'termine'
order by k desc nulls last