Add fetchWorker for fetching off the main thread

This commit is contained in:
Alex Gleason
2023-11-28 18:44:23 -06:00
parent 81971df7fd
commit 3a85e3f8bf
7 changed files with 56 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { TTLCache, unfurl } from '@/deps.ts';
import { Time } from '@/utils/time.ts';
import { fetchWorker } from '@/workers/fetch.ts';
interface PreviewCard {
url: string;
@@ -22,7 +23,7 @@ async function unfurlCard(url: string, signal: AbortSignal): Promise<PreviewCard
console.log(`Unfurling ${url}...`);
try {
const result = await unfurl(url, {
fetch: (url) => fetch(url, { signal }),
fetch: (url) => fetchWorker(url, { signal }),
});
return {