From 8a971dfe5243c9fd62d5ff2c3a25670b104b8bf2 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 17 Oct 2025 22:50:07 +0200 Subject: [PATCH] refactor: pass bookmarks as props to Me component Updated Me.tsx to receive bookmarks from centralized App state: - Added bookmarks and bookmarksLoading to MeProps - Removed local bookmarks state - Removed bookmark caching (now handled at App level) Updated Bookmarks.tsx to pass bookmarks props to Me component: - Both 'me' and 'profile' views receive centralized bookmarks All bookmark data now flows from App.tsx -> Bookmarks.tsx -> Me.tsx with no duplicate fetching or local state. --- src/components/Bookmarks.tsx | 4 ++-- src/components/Me.tsx | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index e65dceb6..f8617898 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -325,10 +325,10 @@ const Bookmarks: React.FC = ({ relayPool ? : null ) : undefined} me={showMe ? ( - relayPool ? : null + relayPool ? : null ) : undefined} profile={showProfile && profilePubkey ? ( - relayPool ? : null + relayPool ? : null ) : undefined} support={showSupport ? ( relayPool ? : null diff --git a/src/components/Me.tsx b/src/components/Me.tsx index 3abef946..c4a55f5c 100644 --- a/src/components/Me.tsx +++ b/src/components/Me.tsx @@ -36,6 +36,8 @@ interface MeProps { relayPool: RelayPool activeTab?: TabType pubkey?: string // Optional pubkey for viewing other users' profiles + bookmarks: Bookmark[] // From centralized App.tsx state + bookmarksLoading: boolean // From centralized App.tsx state } type TabType = 'highlights' | 'reading-list' | 'reads' | 'links' | 'writings' @@ -43,7 +45,13 @@ type TabType = 'highlights' | 'reading-list' | 'reads' | 'links' | 'writings' // Valid reading progress filters const VALID_FILTERS: ReadingProgressFilterType[] = ['all', 'unopened', 'started', 'reading', 'completed'] -const Me: React.FC = ({ relayPool, activeTab: propActiveTab, pubkey: propPubkey }) => { +const Me: React.FC = ({ + relayPool, + activeTab: propActiveTab, + pubkey: propPubkey, + bookmarks, + bookmarksLoading +}) => { const activeAccount = Hooks.useActiveAccount() const navigate = useNavigate() const { filter: urlFilter } = useParams<{ filter?: string }>() @@ -53,7 +61,6 @@ const Me: React.FC = ({ relayPool, activeTab: propActiveTab, pubkey: pr const viewingPubkey = propPubkey || activeAccount?.pubkey const isOwnProfile = !propPubkey || (activeAccount?.pubkey === propPubkey) const [highlights, setHighlights] = useState([]) - const [bookmarks, setBookmarks] = useState([]) const [reads, setReads] = useState([]) const [, setReadsMap] = useState>(new Map()) const [links, setLinks] = useState([]) @@ -251,7 +258,7 @@ const Me: React.FC = ({ relayPool, activeTab: propActiveTab, pubkey: pr const cached = getCachedMeData(viewingPubkey) if (cached) { setHighlights(cached.highlights) - setBookmarks(cached.bookmarks) + // Bookmarks come from App.tsx centralized state, no local caching needed setReads(cached.reads || []) setLinks(cached.links || []) }