- Mon profil est gardé sur l'appareil (effacé à la déconnexion) : photo et pseudo sans attendre le serveur - Rafraîchi en une seule requête au lieu de deux quand le pseudo est connu - Ma page profil s'ouvre directement avec ces données, puis se met à jour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
4 files changed
+59
-7
No files matched your search
@@ -54,7 +54,8 @@ function Stat({ value, label, onClick }: { value?: number; label: string; onClic
|
||||
export default function ProfileView({ username, onClose }: { username: string; onClose: () => void }) {
|
||||
const social = useSocial()
|
||||
const { settings, items: myItems } = useMedia()
|
||||
const [profile, setProfile] = useState<Profile | null>()
|
||||
// Mon profil : affiché tout de suite avec ce qu'on a déjà, puis rechargé
|
||||
const [profile, setProfile] = useState<Profile | null | undefined>(() => (social.me?.username === username ? social.me : undefined))
|
||||
const [error, setError] = useState<string>()
|
||||
const [tab, setTab] = useState<'profile' | 'top' | 'library'>('profile')
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createContext, lazy, Suspense, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { getFollowRequests, getMyProfile, unreadNotifications, type Profile, type ProfileCard } from '../../lib/cloud/social'
|
||||
import { cachedMyProfile, getFollowRequests, getMyProfile, unreadNotifications, type Profile, type ProfileCard } from '../../lib/cloud/social'
|
||||
import { useMedia } from '../../store'
|
||||
import type { MediaItem } from '../../types'
|
||||
import type { PeekOwner } from './ItemPeek'
|
||||
@@ -106,7 +106,14 @@ export function SocialProvider({
|
||||
}) {
|
||||
const { account, items } = useMedia()
|
||||
const enabled = !!account
|
||||
const [me, setMe] = useState<Profile | null>(null)
|
||||
// Profil gardé sur l'appareil : photo et pseudo tout de suite, sans attendre le serveur
|
||||
const [me, setMe] = useState<Profile | null>(() => (enabled ? cachedMyProfile() : null))
|
||||
const [meFor, setMeFor] = useState(account?.email)
|
||||
if (meFor !== account?.email) {
|
||||
// Autre compte (ou déconnexion) : on repart de son propre profil gardé
|
||||
setMeFor(account?.email)
|
||||
setMe(enabled ? cachedMyProfile() : null)
|
||||
}
|
||||
const [requests, setRequests] = useState<ProfileCard[]>([])
|
||||
const [unread, setUnread] = useState(0)
|
||||
const [stack, setStack] = useState<(Overlay & { uid: number })[]>([])
|
||||
|
||||
Reference in new issue
Block a user