Skip to content

Commit c50f3ae

Browse files
committed
refactor: extracting clickable generation logic
1 parent 2170549 commit c50f3ae

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

apps/masterbots.ai/components/routes/chat/chat-clickable-text.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ export function ClickableText({
2121
}: ClickableTextProps) {
2222
const { webSearch } = useThread()
2323

24-
// Choose extraction method based on webSearch state
24+
// * Choose extraction method based on webSearch state
2525
const extractedContent = webSearch
2626
? extractTextFromReactNodeWeb(children)
2727
: extractTextFromReactNodeNormal(children)
2828

29-
// Handle click
3029
const createClickHandler = (text: string) => () => {
3130
if (sendMessageFromResponse && text.trim()) {
32-
const cleanedText = cleanClickableText(text) // Use the cleanClickableText utility
31+
const cleanedText = cleanClickableText(text)
3332
sendMessageFromResponse(`Tell me more about ${cleanedText}`)
3433
}
3534
}
3635

37-
// Common render function
3836
const renderClickableContent = (clickableText: string, restText: string) => (
3937
<>
4038
<span
@@ -52,7 +50,6 @@ export function ClickableText({
5250
</>
5351
)
5452

55-
// Handle array of content
5653
if (Array.isArray(extractedContent)) {
5754
return extractedContent.map((content, index) => {
5855
if (React.isValidElement(content)) {
@@ -73,12 +70,10 @@ export function ClickableText({
7370
})
7471
}
7572

76-
// Handle single React element
7773
if (React.isValidElement(extractedContent)) {
7874
return extractedContent
7975
}
8076

81-
// Handle single text content
8277
const { clickableText, restText } = parseClickableText(
8378
String(extractedContent)
8479
)

0 commit comments

Comments
 (0)