From b3132b7e84575e91f3e356b0f9c4f389d67f6691 Mon Sep 17 00:00:00 2001 From: lipexama <301595999+lipexama@users.noreply.github.com> Date: Wed, 19 Aug 2026 21:47:59 -0500 Subject: [PATCH] perf(lnori): open novels fast on phones Building a chapter list downloaded every volume page at once (~0.5MB each, dozens for a long series) and parsed each whole page, only to read its table of contents. On mobile that meant ~a minute of loading skeletons, and any single failed request failed the entire novel. Parse just the page's '.length); + }; + + const CONCURRENT_VOLUMES = 4; + const chapters2D: Plugin.ChapterItem[][] = []; + for (let i = 0; i < volumeUrls.length; i += CONCURRENT_VOLUMES) { + const batch = volumeUrls.slice(i, i + CONCURRENT_VOLUMES); + const results = await Promise.all( + batch.map(async volUrl => { + const fullVolUrl = this.site.replace(/\/$/, '') + volUrl; + const volHtml = await fetchText(fullVolUrl); + + const toc = sliceToc(volHtml); + if (toc) { + const fromToc = parseVolume(volUrl, toc, true); + if (fromToc) { + return fromToc; + } + } + return parseVolume(volUrl, volHtml, false) ?? []; + }), + ); + chapters2D.push(...results); + } - const chapters2D = await Promise.all(volumePromises); const chapters = chapters2D.flat(); novel.chapters = chapters.map((chap, idx) => ({