diff options
| author | MohamedBassem <me@mbassem.com> | 2024-06-09 21:05:21 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-06-09 21:05:21 +0000 |
| commit | 6928800a604f05ef62234cb5c3ee1e60fb27ea1a (patch) | |
| tree | 4c0f7c395a25b6db23f6cc6a4fc9c65c6f5ee1a4 /apps/web/components/dashboard/bookmarks/LinkCard.tsx | |
| parent | 546139e82f151b35d6492b7cbf2ac89dbfd5d0b5 (diff) | |
| download | karakeep-6928800a604f05ef62234cb5c3ee1e60fb27ea1a.tar.zst | |
refactor: Extract the bookmark polling logic into a separate shared component
Diffstat (limited to 'apps/web/components/dashboard/bookmarks/LinkCard.tsx')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/LinkCard.tsx | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/apps/web/components/dashboard/bookmarks/LinkCard.tsx b/apps/web/components/dashboard/bookmarks/LinkCard.tsx index 1446b031..7212940b 100644 --- a/apps/web/components/dashboard/bookmarks/LinkCard.tsx +++ b/apps/web/components/dashboard/bookmarks/LinkCard.tsx @@ -2,13 +2,11 @@ import Image from "next/image"; import Link from "next/link"; -import { api } from "@/lib/trpc"; import type { ZBookmarkTypeLink } from "@hoarder/shared/types/bookmarks"; import { getBookmarkLinkImageUrl, isBookmarkStillCrawling, - isBookmarkStillLoading, } from "@hoarder/shared-react/utils/bookmarkUtils"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; @@ -80,38 +78,12 @@ function LinkUrl({ bookmark }: { bookmark: ZBookmarkTypeLink }) { } export default function LinkCard({ - bookmark: initialData, + bookmark: bookmarkLink, className, }: { bookmark: ZBookmarkTypeLink; className?: string; }) { - const { data: bookmark } = api.bookmarks.getBookmark.useQuery( - { - bookmarkId: initialData.id, - }, - { - initialData, - refetchInterval: (query) => { - const data = query.state.data; - if (!data) { - return false; - } - // If the link is not crawled or not tagged - if (isBookmarkStillLoading(data)) { - return 1000; - } - return false; - }, - }, - ); - - if (bookmark.content.type !== "link") { - throw new Error("Invalid bookmark type"); - } - - const bookmarkLink = { ...bookmark, content: bookmark.content }; - return ( <BookmarkLayoutAdaptingCard title={<LinkTitle bookmark={bookmarkLink} />} |
