"use client";
import Image from "next/image";
import { api } from "@/lib/trpc";
import type {
ZBookmark,
ZBookmarkTypeAsset,
} from "@hoarder/shared/types/bookmarks";
import { getAssetUrl } from "@hoarder/shared-react/utils/assetUtils";
import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils";
import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard";
function AssetImage({
bookmark,
className,
}: {
bookmark: ZBookmarkTypeAsset;
className?: string;
}) {
const bookmarkedAsset = bookmark.content;
switch (bookmarkedAsset.assetType) {
case "image": {
return (
);
}
case "pdf": {
return (
);
}
default: {
const _exhaustiveCheck: never = bookmarkedAsset.assetType;
return ;
}
}
}
export default function AssetCard({
bookmark: initialData,
className,
}: {
bookmark: ZBookmark;
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;
},
},
);
if (bookmark.content.type != "asset") {
throw new Error("Unexpected bookmark type");
}
const bookmarkedAsset = { ...bookmark, content: bookmark.content };
return (
(
)}
/>
);
}