From 3208dda3848ad739f54cebf44c423e2b68e85b2d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 28 Feb 2024 20:45:28 +0000 Subject: feature: Add support for storing and previewing raw notes --- .../dashboard/bookmarks/components/LinkCard.tsx | 50 ++++++---------------- 1 file changed, 12 insertions(+), 38 deletions(-) (limited to 'packages/web/app/dashboard/bookmarks/components/LinkCard.tsx') diff --git a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx index cd0f128c..73d3f300 100644 --- a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx +++ b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx @@ -1,6 +1,5 @@ "use client"; -import { Badge } from "@/components/ui/badge"; import { ImageCard, ImageCardBanner, @@ -13,50 +12,24 @@ import { ZBookmark } from "@/lib/types/api/bookmarks"; import Link from "next/link"; import BookmarkOptions from "./BookmarkOptions"; import { api } from "@/lib/trpc"; -import { Skeleton } from "@/components/ui/skeleton"; import { Star } from "lucide-react"; +import { cn } from "@/lib/utils"; +import TagList from "./TagList"; function isStillCrawling(bookmark: ZBookmark) { return ( + bookmark.content.type == "link" && !bookmark.content.crawledAt && Date.now().valueOf() - bookmark.createdAt.valueOf() < 30 * 1000 ); } -function TagList(bookmark: ZBookmark, stillCrawling: boolean) { - if (stillCrawling) { - return ( - - - - - - ); - } - return ( - - {bookmark.tags.map((t) => ( - - - #{t.name} - - - ))} - - ); -} - export default function LinkCard({ bookmark: initialData, + className, }: { bookmark: ZBookmark; + className: string; }) { const { data: bookmark } = api.bookmarks.getBookmark.useQuery( { @@ -78,6 +51,9 @@ export default function LinkCard({ }, ); const link = bookmark.content; + if (link.type != "link") { + throw new Error("Unexpected bookmark type"); + } const isCrawling = isStillCrawling(bookmark); const parsedUrl = new URL(link.url); @@ -88,11 +64,7 @@ export default function LinkCard({ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="; return ( - + {bookmark.favourited && ( {/* There's a hack here. Every tag has the full hight of the container itself. That why, when we enable flex-wrap, the overflowed don't show up. */} - {TagList(bookmark, isCrawling)} + + +
-- cgit v1.2.3-70-g09d2