From adb3beb2b1c46a7ff0e84c1a687f147b0e65ddfa Mon Sep 17 00:00:00 2001 From: SethBurkart123 Date: Fri, 15 Aug 2025 10:22:10 +1000 Subject: [PATCH] perf: limit notice length in preview --- src/seqta/utils/Loaders/LoadHomePage.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/seqta/utils/Loaders/LoadHomePage.ts b/src/seqta/utils/Loaders/LoadHomePage.ts index 18bbe1ab..7a1eda0c 100644 --- a/src/seqta/utils/Loaders/LoadHomePage.ts +++ b/src/seqta/utils/Loaders/LoadHomePage.ts @@ -44,7 +44,7 @@ export async function loadHomePage() { const homeContainer = document.getElementById("home-root"); if (!homeContainer) return; - const skeletonStructure = stringToHTML(` + const skeletonStructure = stringToHTML(/* html */`
@@ -420,9 +420,14 @@ function processNoticeColor(colour: string): string | undefined { } function createNoticeElement(notice: any, colour: string | undefined): Node { - const cleanContent = notice.contents + const textPreview = notice.contents + .replace(/<[^>]*>/g, "") .replace(/\[\[[\w]+[:][\w]+[\]\]]+/g, "") - .replace(/ +/, " "); + .replace(/\s+/g, " ") + .trim() + .substring(0, 150) + + (notice.contents.length > 150 ? "..." : ""); + const noticeId = `notice-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; const htmlContent = ` @@ -437,7 +442,7 @@ function createNoticeElement(notice: any, colour: string | undefined): Node {

${notice.title}

-
${cleanContent}
+
${textPreview}
`; const element = stringToHTML(htmlContent).firstChild as HTMLElement;