import { useAutoAnimate } from "@formkit/auto-animate/react"; import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { EditButton } from "@/components/buttons/EditButton"; import { Icons } from "@/components/Icon"; import { SectionHeading } from "@/components/layout/SectionHeading"; import { MediaGrid } from "@/components/media/MediaGrid"; import { WatchedMediaCard } from "@/components/media/WatchedMediaCard"; import { useBookmarkStore } from "@/stores/bookmarks"; import { MediaItem } from "@/utils/mediaTypes"; export function BookmarksPart() { const { t } = useTranslation(); const bookmarks = useBookmarkStore((s) => s.bookmarks); const removeBookmark = useBookmarkStore((s) => s.removeBookmark); const [editing, setEditing] = useState(false); const [gridRef] = useAutoAnimate(); // TODO sort on last watched const items = useMemo(() => { const output: MediaItem[] = []; Object.entries(bookmarks).forEach((entry) => { output.push({ id: entry[0], ...entry[1], }); }); return output; }, [bookmarks]); if (items.length === 0) return null; return (
{items.map((v) => ( removeBookmark(v.id)} /> ))}
); }