import { useState, useEffect } from "react"; import { Link } from "react-router-dom"; import { useAuth } from "../context/AuthContext"; import { getUserHighlights, deleteHighlight } from "../api/client"; import { HighlightIcon } from "../components/Icons"; import { HighlightCard } from "../components/AnnotationCard"; export default function Highlights() { const { user, isAuthenticated, loading } = useAuth(); const [highlights, setHighlights] = useState([]); const [loadingHighlights, setLoadingHighlights] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function loadHighlights() { if (!user?.did) return; try { setLoadingHighlights(true); const data = await getUserHighlights(user.did); setHighlights(data.items || []); } catch (err) { console.error("Failed to load highlights:", err); setError(err.message); } finally { setLoadingHighlights(false); } } if (isAuthenticated && user) { loadHighlights(); } }, [isAuthenticated, user]); const handleDelete = async (uri) => { if (!confirm("Delete this highlight?")) return; try { const parts = uri.split("/"); const rkey = parts[parts.length - 1]; await deleteHighlight(rkey); setHighlights((prev) => prev.filter((h) => (h.id || h.uri) !== uri)); } catch (err) { alert("Failed to delete: " + err.message); } }; if (loading) return (
); if (!isAuthenticated) { return (

Sign in to view your highlights

You need to be logged in with your Bluesky account

Sign in with Bluesky
); } return (

My Highlights

Text you've highlighted across the web

{loadingHighlights ? (
{[1, 2, 3].map((i) => (
))}
) : error ? (
⚠️

Error loading highlights

{error}

) : highlights.length === 0 ? (

No highlights yet

Highlight text on any page using the browser extension.

) : (
{highlights.map((highlight) => ( ))}
)}
); }