From c5884f8d5560a4fe814782816eb33060d0ce21fd Mon Sep 17 00:00:00 2001 From: jzitnik-dev Date: Fri, 19 Jun 2026 10:02:13 +0200 Subject: [PATCH] fix: I don't even fucking know --- scrape/parse/v3.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scrape/parse/v3.ts b/scrape/parse/v3.ts index 7673d68..3102505 100644 --- a/scrape/parse/v3.ts +++ b/scrape/parse/v3.ts @@ -274,6 +274,7 @@ function buildLessonArray(row: Row, ignoreAddress: string, themeColors: ThemeCol const colIndex = letterToNumber(cell.address.replace(/[0-9]/g, "")); lessons[colIndex] = parseLessonCell(cell, themeColors, ignoreColors); + console.log(lessons[colIndex]) }); const normalized = Array.from(lessons, (x) => (x === undefined ? null : x)); @@ -284,23 +285,25 @@ function buildLessonArray(row: Row, ignoreAddress: string, themeColors: ThemeCol function parseLessonCell(cell: Cell, themeColors: ThemeColors | null, ignoreColors: boolean): Lesson | null { try { - const text = (cell.text || "").trim(); + const text = cell.text.trim(); const cleanupRegex = /^úklid\s+(?:\d+\s+)?[A-Za-z]{2}$/; + // I thought that doing just !text will be enough, but NO. Apparently if text is empty the text isn't null or empty. It's fucking "[object Object]". I have no idea who thought this would be a good idea but here we are. It worked before just because .argb was throwing error and settings the whole value to null in the catch block. // @ts-ignore - if (!text || cleanupRegex.test(text) || (!cell.fill?.fgColor && !ignoreColors)) return null; + if (!text || text === "[object Object]" || cleanupRegex.test(text) || (!cell.fill?.fgColor && !ignoreColors)) return null; const backgroundColor = resolveCellColor(cell, themeColors); const foregroundColor = !backgroundColor ? undefined : ( cell.font?.color?.argb === undefined ? "#FF000000" : `#${cell.font.color.argb}` ); + return { text, backgroundColor, foregroundColor, // @ts-ignore - willBeSpecified: cell.fill.fgColor.argb === "FFFFFF00" ? true : undefined, + willBeSpecified: cell.fill.fgColor?.argb === "FFFFFF00" ? true : undefined, }; } catch { return null;