bug fix + ui improvements

This commit is contained in:
Daniel
2023-07-24 10:06:24 -04:00
parent cbf53f6e30
commit 1086e22451
3 changed files with 27 additions and 21 deletions
+5 -5
View File
@@ -124,11 +124,10 @@ export default function AddOrEditLink({
</p> </p>
) : null} ) : null}
<div className="grid sm:grid-cols-2 gap-3">
{method === "CREATE" ? ( {method === "CREATE" ? (
<div className="sm:col-span-2"> <div>
<p className="text-sm text-sky-700 mb-2"> <p className="text-sm text-sky-700 mb-2 font-bold">
URL Address (URL)
<RequiredBadge /> <RequiredBadge />
</p> </p>
<input <input
@@ -140,7 +139,8 @@ export default function AddOrEditLink({
/> />
</div> </div>
) : null} ) : null}
<hr />
<div className="grid sm:grid-cols-2 gap-3">
<div> <div>
<p className="text-sm text-sky-700 mb-2">Collection</p> <p className="text-sm text-sky-700 mb-2">Collection</p>
<CollectionSelection <CollectionSelection
+1 -1
View File
@@ -150,7 +150,7 @@ export default function LinkDetails({ link }: Props) {
}} }}
/> />
)} )}
<div className="flex flex-col gap- justify-end drop-shadow"> <div className="flex flex-col min-h-[3rem] justify-end drop-shadow">
<p className="text-2xl text-sky-700 capitalize break-words hyphens-auto"> <p className="text-2xl text-sky-700 capitalize break-words hyphens-auto">
{link.name} {link.name}
</p> </p>
+10 -4
View File
@@ -7,12 +7,12 @@ export default async function archive(
collectionId: number, collectionId: number,
linkId: number linkId: number
) { ) {
const browser = await chromium.launch(); const browser = await chromium.launch({ headless: false });
const context = await browser.newContext(devices["Desktop Chrome"]); const context = await browser.newContext(devices["Desktop Chrome"]);
const page = await context.newPage(); const page = await context.newPage();
try { try {
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 300000 }); await page.goto(url, { waitUntil: "domcontentloaded" });
await autoScroll(page); await autoScroll(page);
@@ -53,7 +53,13 @@ export default async function archive(
const autoScroll = async (page: Page) => { const autoScroll = async (page: Page) => {
await page.evaluate(async () => { await page.evaluate(async () => {
await new Promise<void>((resolve, reject) => { const timeoutPromise = new Promise<void>((_, reject) => {
setTimeout(() => {
reject(new Error("Auto scroll took too long (more than 10 seconds)."));
}, 20000);
});
const scrollingPromise = new Promise<void>((resolve) => {
let totalHeight = 0; let totalHeight = 0;
let distance = 100; let distance = 100;
let scrollDown = setInterval(() => { let scrollDown = setInterval(() => {
@@ -68,6 +74,6 @@ const autoScroll = async (page: Page) => {
}, 100); }, 100);
}); });
await new Promise((r) => setTimeout(r, 2000)); await Promise.race([scrollingPromise, timeoutPromise]);
}); });
}; };