mirror of
https://github.com/hoornet/vega.git
synced 2026-04-24 06:40:01 -07:00
Fix profile cache invalidation after editing
Invalidate the in-memory profile cache for the user's pubkey after publishing a new kind 0 event, so the updated profile reflects immediately. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -4,6 +4,11 @@ import { fetchProfile } from "../lib/nostr";
|
||||
const profileCache = new Map<string, any>();
|
||||
const pendingRequests = new Map<string, Promise<any>>();
|
||||
|
||||
export function invalidateProfileCache(pubkey: string) {
|
||||
profileCache.delete(pubkey);
|
||||
pendingRequests.delete(pubkey);
|
||||
}
|
||||
|
||||
export function useProfile(pubkey: string) {
|
||||
const [profile, setProfile] = useState<any>(profileCache.get(pubkey) ?? null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user