Skip to content

Commit

Permalink
truncate urgent message title
Browse files Browse the repository at this point in the history
  • Loading branch information
guytepper committed Oct 8, 2023
1 parent 00b0253 commit aa0c803
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/screens/planner/planner-screen-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,24 @@ export const PlannerScreenHeader = observer(function PlannerScreenHeader() {

{showUrgentBar && (
<View style={{ position: "absolute", top: 0, left: 16 }}>
<ImportantAnnouncementBar title={head(popupMessages)?.messageBody} />
<ImportantAnnouncementBar title={truncateString(head(popupMessages)?.messageBody, 5)} />
</View>
)}
</>
)
})

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
}
}

0 comments on commit aa0c803

Please sign in to comment.