From aa0c8037579ea11c30567ed6f4fe798caff96369 Mon Sep 17 00:00:00 2001 From: Guy Tepper Date: Sun, 8 Oct 2023 08:19:04 -0300 Subject: [PATCH] truncate urgent message title --- app/screens/planner/planner-screen-header.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/screens/planner/planner-screen-header.tsx b/app/screens/planner/planner-screen-header.tsx index a01a30ceb..80f0ed329 100644 --- a/app/screens/planner/planner-screen-header.tsx +++ b/app/screens/planner/planner-screen-header.tsx @@ -114,9 +114,24 @@ export const PlannerScreenHeader = observer(function PlannerScreenHeader() { {showUrgentBar && ( - + )} ) }) + +function truncateString(inputString, numWords) { + // Split the input string into an array of words + const words = inputString.split(" ") + + // Take the first 'numWords' words and join them back into a string + const truncatedString = words.slice(0, numWords).join(" ") + + // Add "..." to the end if there are more words in the original string + if (words.length > numWords) { + return truncatedString + " ..." + } else { + return truncatedString + } +}