Fix stale profile data #214

Merged
enes merged 6 commits from issues/208-profile-box-cache into staging 2025-02-03 16:43:49 +00:00
Showing only changes of commit 734f8e6d8c - Show all commits

View File

@ -123,12 +123,13 @@ export const ProfileSettings = () => {
} }
const handlePublish = async () => { const handlePublish = async () => {
if (!userState.auth && !userState.user?.pubkey) return if (!userState.auth || !userState.user?.pubkey) return
setIsPublishing(true) setIsPublishing(true)
const prevProfile = userState.user as NDKUserProfile const prevProfile = userState.user as NDKUserProfile
const updatedProfile = { const createdAt = now()
const updatedProfile: NDKUserProfile = {
...prevProfile, ...prevProfile,
name: formState.name, name: formState.name,
displayName: formState.displayName, displayName: formState.displayName,
@ -136,16 +137,16 @@ export const ProfileSettings = () => {
picture: formState.picture, picture: formState.picture,
banner: formState.banner, banner: formState.banner,
nip05: formState.nip05, nip05: formState.nip05,
lud16: formState.lud16 lud16: formState.lud16,
created_at: createdAt
} }
const serializedProfile = serializeProfile(updatedProfile) const serializedProfile = serializeProfile(updatedProfile)
const unsignedEvent: UnsignedEvent = { const unsignedEvent: UnsignedEvent = {
kind: kinds.Metadata, kind: kinds.Metadata,
tags: [], tags: [],
content: serializedProfile, content: serializedProfile,
created_at: now(), created_at: createdAt,
pubkey: userState.user?.pubkey as string pubkey: userState.user?.pubkey as string
} }
@ -176,7 +177,6 @@ export const ProfileSettings = () => {
)}` )}`
) )
const ndkEvent = new NDKEvent(undefined, signedEvent)
const userProfile = profileFromEvent(ndkEvent) const userProfile = profileFromEvent(ndkEvent)
dispatch(setUser(userProfile)) dispatch(setUser(userProfile))
} }