diff --git a/src/components/profile/ProfileView.tsx b/src/components/profile/ProfileView.tsx index b044f66..e3f716f 100644 --- a/src/components/profile/ProfileView.tsx +++ b/src/components/profile/ProfileView.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; import { NDKEvent } from "@nostr-dev-kit/ndk"; import { useUIStore } from "../../stores/ui"; import { useUserStore } from "../../stores/user"; -import { useProfile } from "../../hooks/useProfile"; +import { useProfile, invalidateProfileCache } from "../../hooks/useProfile"; import { fetchUserNotes, publishProfile } from "../../lib/nostr"; import { shortenPubkey } from "../../lib/utils"; import { NoteCard } from "../feed/NoteCard"; @@ -25,6 +25,7 @@ function EditProfileForm({ pubkey, onSaved }: { pubkey: string; onSaved: () => v setSaving(true); setError(null); try { + invalidateProfileCache(pubkey); await publishProfile({ name: name.trim() || undefined, display_name: displayName.trim() || undefined, diff --git a/src/hooks/useProfile.ts b/src/hooks/useProfile.ts index e85713e..45df829 100644 --- a/src/hooks/useProfile.ts +++ b/src/hooks/useProfile.ts @@ -4,6 +4,11 @@ import { fetchProfile } from "../lib/nostr"; const profileCache = new Map(); const pendingRequests = new Map>(); +export function invalidateProfileCache(pubkey: string) { + profileCache.delete(pubkey); + pendingRequests.delete(pubkey); +} + export function useProfile(pubkey: string) { const [profile, setProfile] = useState(profileCache.get(pubkey) ?? null);