diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 73b92fd9..3db7ba0b 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -31,6 +31,9 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { const navigate = useNavigate() const previousLocationRef = useRef() + // Check for highlight navigation state + const navigationState = location.state as { highlightId?: string; openHighlights?: boolean } | null + const externalUrl = location.pathname.startsWith('/r/') ? decodeURIComponent(location.pathname.slice(3)) : undefined @@ -128,6 +131,19 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname]) + // Handle highlight navigation from explore page + useEffect(() => { + if (navigationState?.highlightId && navigationState?.openHighlights) { + // Open the highlights sidebar + setIsHighlightsCollapsed(false) + // Select the highlight (scroll happens automatically in useHighlightInteractions) + setSelectedHighlightId(navigationState.highlightId) + + // Clear the state after handling to avoid re-triggering + navigate(location.pathname, { replace: true, state: {} }) + } + }, [navigationState, setIsHighlightsCollapsed, setSelectedHighlightId, navigate, location.pathname]) + const { bookmarks, bookmarksLoading, diff --git a/src/components/Explore.tsx b/src/components/Explore.tsx index f3a164b3..128a2ee5 100644 --- a/src/components/Explore.tsx +++ b/src/components/Explore.tsx @@ -219,15 +219,15 @@ const Explore: React.FC = ({ relayPool, activeTab: propActiveTab } pubkey, identifier }) - navigate(`/a/${naddr}`) + navigate(`/a/${naddr}`, { state: { highlightId, openHighlights: true } }) } else { // Already an naddr - navigate(`/a/${highlight.eventReference}`) + navigate(`/a/${highlight.eventReference}`, { state: { highlightId, openHighlights: true } }) } } // For web URLs else if (highlight.urlReference) { - navigate(`/r/${encodeURIComponent(highlight.urlReference)}`) + navigate(`/r/${encodeURIComponent(highlight.urlReference)}`, { state: { highlightId, openHighlights: true } }) } }