From e6486465decd612f7e437abe904960a47ff359ce Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Mon, 1 Jul 2024 13:03:53 +0200 Subject: refactor: added the bookmark type to the database (#256) * refactoring asset types Extracted out functions to silently delete assets and to update them after crawling Generalized the mapping of assets to bookmark fields to make extending them easier * Added the bookmark type to the database Introduced an enum to have better type safety cleaned up the code and based some code on the type directly * add BookmarkType.UNKNWON * lint and remove unused function --------- Co-authored-by: MohamedBassem --- apps/web/components/dashboard/preview/BookmarkPreview.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'apps/web/components/dashboard/preview/BookmarkPreview.tsx') diff --git a/apps/web/components/dashboard/preview/BookmarkPreview.tsx b/apps/web/components/dashboard/preview/BookmarkPreview.tsx index 6a1068af..01e57e05 100644 --- a/apps/web/components/dashboard/preview/BookmarkPreview.tsx +++ b/apps/web/components/dashboard/preview/BookmarkPreview.tsx @@ -17,11 +17,11 @@ import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; import { CalendarDays, ExternalLink } from "lucide-react"; -import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { isBookmarkStillCrawling, isBookmarkStillLoading, } from "@hoarder/shared-react/utils/bookmarkUtils"; +import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; import ActionBar from "./ActionBar"; import { AssetContentSection } from "./AssetContentSection"; @@ -66,10 +66,10 @@ function CreationTime({ createdAt }: { createdAt: Date }) { } function getSourceUrl(bookmark: ZBookmark) { - if (bookmark.content.type === "link") { + if (bookmark.content.type === BookmarkTypes.LINK) { return bookmark.content.url; } - if (bookmark.content.type === "asset") { + if (bookmark.content.type === BookmarkTypes.ASSET) { return bookmark.content.sourceUrl; } return null; @@ -108,15 +108,15 @@ export default function BookmarkPreview({ let content; switch (bookmark.content.type) { - case "link": { + case BookmarkTypes.LINK: { content = ; break; } - case "text": { + case BookmarkTypes.TEXT: { content = ; break; } - case "asset": { + case BookmarkTypes.ASSET: { content = ; break; } -- cgit v1.2.3-70-g09d2