From d9919992443c4bb6fa6b5e3f6e71a2fa2d4b419f Mon Sep 17 00:00:00 2001 From: Paul Rupke Date: Fri, 1 Aug 2025 23:40:34 -0400 Subject: [PATCH 1/3] parse full line number with optional letter from skeet --- src/components/alerts/AlertUtils.tsx | 2 +- src/components/alerts/bsky-alerts/SkeetList.tsx | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/alerts/AlertUtils.tsx b/src/components/alerts/AlertUtils.tsx index 529c075..d497d55 100644 --- a/src/components/alerts/AlertUtils.tsx +++ b/src/components/alerts/AlertUtils.tsx @@ -18,7 +18,7 @@ export const ParsedTtcAlertText = ({ const lineFilter = badge.line ? lineNum < 6 ? `${lineNum}` - : `${lineNum}` + : badge.line : badge.highlightAll ? parseLine(feedText) : ""; diff --git a/src/components/alerts/bsky-alerts/SkeetList.tsx b/src/components/alerts/bsky-alerts/SkeetList.tsx index 865156a..741037a 100644 --- a/src/components/alerts/bsky-alerts/SkeetList.tsx +++ b/src/components/alerts/bsky-alerts/SkeetList.tsx @@ -1,6 +1,15 @@ import { type Skeet, SkeetElement } from "./Skeet.js"; import style from "./SkeetList.module.css"; +const parseFullLineNumber = (skeets: Skeet[]) => { + if (skeets?.length === 0) { + return; + } + // Match the line number as well as any possible suffix (e.g. "A" or "B") + const lineTextMatch = skeets[0].post.record.text.match(/^\d{1,3}\S/); + return lineTextMatch?.[0]; +}; + export const SkeetList = ({ skeetList, line, @@ -10,7 +19,11 @@ export const SkeetList = ({ line?: string; type?: string; }) => { - const badgeArg = line === "all" ? { highlightAll: true } : { line }; + const lineNumber = parseFullLineNumber(skeetList); + const badgeArg = + line === "all" + ? { highlightAll: true } + : { line: typeof lineNumber === "string" ? lineNumber : line }; const dataArray = skeetList.map((skeet) => ( )); From 695252e10516047964a7acd27e11387d278ddc29 Mon Sep 17 00:00:00 2001 From: Paul Rupke Date: Fri, 1 Aug 2025 23:54:43 -0400 Subject: [PATCH 2/3] clarify comment --- src/components/alerts/bsky-alerts/SkeetList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/alerts/bsky-alerts/SkeetList.tsx b/src/components/alerts/bsky-alerts/SkeetList.tsx index 741037a..2d612a2 100644 --- a/src/components/alerts/bsky-alerts/SkeetList.tsx +++ b/src/components/alerts/bsky-alerts/SkeetList.tsx @@ -5,7 +5,7 @@ const parseFullLineNumber = (skeets: Skeet[]) => { if (skeets?.length === 0) { return; } - // Match the line number as well as any possible suffix (e.g. "A" or "B") + // Match the line number as well as any possible suffix (e.g. matches "96" or "96A") const lineTextMatch = skeets[0].post.record.text.match(/^\d{1,3}\S/); return lineTextMatch?.[0]; }; From de395e550a8d30e203c1d7ae66dc7f65c29c7396 Mon Sep 17 00:00:00 2001 From: Paul Rupke Date: Sat, 2 Aug 2025 13:47:27 -0400 Subject: [PATCH 3/3] clean up function --- src/components/alerts/bsky-alerts/SkeetList.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/alerts/bsky-alerts/SkeetList.tsx b/src/components/alerts/bsky-alerts/SkeetList.tsx index 2d612a2..0c84084 100644 --- a/src/components/alerts/bsky-alerts/SkeetList.tsx +++ b/src/components/alerts/bsky-alerts/SkeetList.tsx @@ -1,13 +1,10 @@ import { type Skeet, SkeetElement } from "./Skeet.js"; import style from "./SkeetList.module.css"; -const parseFullLineNumber = (skeets: Skeet[]) => { - if (skeets?.length === 0) { - return; - } +const parseFullLineNumber = (skeet: Skeet) => { // Match the line number as well as any possible suffix (e.g. matches "96" or "96A") - const lineTextMatch = skeets[0].post.record.text.match(/^\d{1,3}\S/); - return lineTextMatch?.[0]; + const lineTextMatch = skeet.post.record.text.match(/^\d{1,3}\S/); + return lineTextMatch?.[0] ?? null; }; export const SkeetList = ({ @@ -19,11 +16,10 @@ export const SkeetList = ({ line?: string; type?: string; }) => { - const lineNumber = parseFullLineNumber(skeetList); + const lineNumber = + skeetList?.length > 0 ? parseFullLineNumber(skeetList?.[0]) : line; const badgeArg = - line === "all" - ? { highlightAll: true } - : { line: typeof lineNumber === "string" ? lineNumber : line }; + line === "all" ? { highlightAll: true } : { line: lineNumber }; const dataArray = skeetList.map((skeet) => ( ));