import { memo, useMemo, useState } from "react"; import { getVscodeIconUrlForEntry } from "../../vscode-icons"; import { FileIcon, FolderIcon } from "lucide-react"; import { cn } from "~/lib/utils"; export const VscodeEntryIcon = memo(function VscodeEntryIcon(props: { pathValue: string; kind: "file" | "directory"; theme: "light" | "dark"; className?: string; }) { const [failedIconUrl, setFailedIconUrl] = useState(null); const iconUrl = useMemo( () => getVscodeIconUrlForEntry(props.pathValue, props.kind, props.theme), [props.kind, props.pathValue, props.theme], ); const failed = failedIconUrl === iconUrl; if (failed) { return props.kind === "directory" ? ( ) : ( ); } return ( setFailedIconUrl(iconUrl)} /> ); });