feat: support sending and preview links

This commit is contained in:
talksik
2026-03-21 12:46:23 -07:00
parent 6bf2f2217a
commit d6b7ecc8fd
8 changed files with 431 additions and 60 deletions
+19
View File
@@ -0,0 +1,19 @@
import { useQuery } from "@tanstack/react-query";
import { extractUrls, type LinkMetadata } from "@/lib/link-metadata";
export function useLinkMetadata(url: string | null) {
return useQuery<LinkMetadata | null>({
queryKey: ["link-metadata", url],
queryFn: () => window.electronLink.fetchMetadata(url!),
enabled: !!url,
staleTime: Infinity,
gcTime: 30 * 60 * 1000,
retry: 1,
});
}
export function useFirstLinkMetadata(text: string) {
const urls = extractUrls(text);
const firstUrl = urls[0] ?? null;
return { ...useLinkMetadata(firstUrl), url: firstUrl };
}