diff --git a/components/Modal/Link/AddOrEditLink.tsx b/components/Modal/Link/AddOrEditLink.tsx index 205513c..e072abd 100644 --- a/components/Modal/Link/AddOrEditLink.tsx +++ b/components/Modal/Link/AddOrEditLink.tsx @@ -124,23 +124,23 @@ export default function AddOrEditLink({

) : null} + {method === "CREATE" ? ( +
+

+ Address (URL) + +

+ setLink({ ...link, url: e.target.value })} + type="text" + placeholder="e.g. http://example.com/" + className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-700 duration-100" + /> +
+ ) : null} +
- {method === "CREATE" ? ( -
-

- URL - -

- setLink({ ...link, url: e.target.value })} - type="text" - placeholder="e.g. http://example.com/" - className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-700 duration-100" - /> -
- ) : null} -

Collection

)} -
+

{link.name}

diff --git a/lib/api/archive.ts b/lib/api/archive.ts index 546c76e..d03b1e9 100644 --- a/lib/api/archive.ts +++ b/lib/api/archive.ts @@ -7,12 +7,12 @@ export default async function archive( collectionId: number, linkId: number ) { - const browser = await chromium.launch(); + const browser = await chromium.launch({ headless: false }); const context = await browser.newContext(devices["Desktop Chrome"]); const page = await context.newPage(); try { - await page.goto(url, { waitUntil: "domcontentloaded", timeout: 300000 }); + await page.goto(url, { waitUntil: "domcontentloaded" }); await autoScroll(page); @@ -53,7 +53,13 @@ export default async function archive( const autoScroll = async (page: Page) => { await page.evaluate(async () => { - await new Promise((resolve, reject) => { + const timeoutPromise = new Promise((_, reject) => { + setTimeout(() => { + reject(new Error("Auto scroll took too long (more than 10 seconds).")); + }, 20000); + }); + + const scrollingPromise = new Promise((resolve) => { let totalHeight = 0; let distance = 100; let scrollDown = setInterval(() => { @@ -68,6 +74,6 @@ const autoScroll = async (page: Page) => { }, 100); }); - await new Promise((r) => setTimeout(r, 2000)); + await Promise.race([scrollingPromise, timeoutPromise]); }); };