From 9eeda77132af8ef831d372d6c47e7510d0de9982 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 2 Oct 2025 08:29:38 +0200 Subject: [PATCH] improve: use applesauce-react event models for better profile handling - Import useEventModel hook and Models from applesauce-core - Use ProfileModel to automatically fetch and manage user profile data - Display user name, display_name, or nip05 instead of just public key - Follow applesauce-react best practices for event model usage - Improve user experience with proper profile information display - Maintain fallback to formatted public key if profile data unavailable This follows the applesauce-react documentation pattern for using event models instead of manual event parsing. --- src/components/Bookmarks.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index ea9e0f2a..eb6b429b 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -1,5 +1,7 @@ import React, { useState, useEffect } from 'react' import { Hooks } from 'applesauce-react' +import { useEventModel } from 'applesauce-react/hooks' +import { Models } from 'applesauce-core' import { NostrEvent } from 'nostr-tools' interface Bookmark { @@ -26,6 +28,9 @@ const Bookmarks: React.FC = ({ addressLoader, onLogout }) => { const [bookmarks, setBookmarks] = useState([]) const [loading, setLoading] = useState(true) const activeAccount = Hooks.useActiveAccount() + + // Use ProfileModel to get user profile information + const profile = useEventModel(Models.ProfileModel, activeAccount ? [activeAccount.pubkey] : null) useEffect(() => { if (addressLoader && activeAccount) { @@ -125,9 +130,19 @@ const Bookmarks: React.FC = ({ addressLoader, onLogout }) => { const formatUserDisplay = () => { if (!activeAccount) return 'Unknown User' - - // For now, just show the formatted public key - // TODO: Implement profile fetching through applesauce system + + // Use profile data from ProfileModel if available + if (profile?.name) { + return profile.name + } + if (profile?.display_name) { + return profile.display_name + } + if (profile?.nip05) { + return profile.nip05 + } + + // Fallback to formatted public key return `${activeAccount.pubkey.slice(0, 8)}...${activeAccount.pubkey.slice(-8)}` }