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/TextCard.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/TextCard.tsx')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/TextCard.tsx | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/apps/web/components/dashboard/bookmarks/TextCard.tsx b/apps/web/components/dashboard/bookmarks/TextCard.tsx index b18efc3d..ffaa18a4 100644 --- a/apps/web/components/dashboard/bookmarks/TextCard.tsx +++ b/apps/web/components/dashboard/bookmarks/TextCard.tsx @@ -2,46 +2,23 @@ import { useState } from "react"; import { MarkdownComponent } from "@/components/ui/markdown-component"; -import { api } from "@/lib/trpc"; import { bookmarkLayoutSwitch } from "@/lib/userLocalSettings/bookmarksLayout"; import { cn } from "@/lib/utils"; -import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; -import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils"; +import type { ZBookmarkTypeText } from "@hoarder/shared/types/bookmarks"; import { BookmarkedTextViewer } from "./BookmarkedTextViewer"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; export default function TextCard({ - bookmark: initialData, + bookmark, className, }: { - bookmark: ZBookmark; + bookmark: ZBookmarkTypeText; 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 (isBookmarkStillTagging(data)) { - return 1000; - } - return false; - }, - }, - ); const [previewModalOpen, setPreviewModalOpen] = useState(false); const bookmarkedText = bookmark.content; - if (bookmarkedText.type != "text") { - throw new Error("Unexpected bookmark type"); - } return ( <> |
