Skip to content

Commit

Permalink
3028: Complexity Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hannaseithe committed Feb 18, 2025
1 parent 252b95a commit 0008c7e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions web/src/components/ChatConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ type TypingIndicatorProps = {
isVisible: boolean
}

const shouldShowIcon = (index: number, message: ChatMessageModel, messages: ChatMessageModel[]): boolean => {
const previousMessage = messages[index - 1];
return (
previousMessage?.userIsAuthor !== message.userIsAuthor ||
previousMessage.isAutomaticAnswer !== message.isAutomaticAnswer
);
}

const TypingIndicator = ({ isVisible }: TypingIndicatorProps): ReactElement | null =>
isVisible ? (
<TypingIndicatorWrapper>
Expand Down Expand Up @@ -84,10 +92,7 @@ const ChatConversation = ({ messages, hasError, className }: ChatConversationPro
<ChatMessage
message={message}
key={message.id}
showIcon={
messages[index - 1]?.userIsAuthor !== message.userIsAuthor ||
messages[index - 1]?.isAutomaticAnswer !== message.isAutomaticAnswer
}
showIcon={shouldShowIcon(index, message, messages)}

Check notice on line 95 in web/src/components/ChatConversation.tsx

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Complex Method

ChatConversation is no longer above the threshold for cyclomatic complexity
/>
))}
<TypingIndicator isVisible={typingIndicatorVisible} />
Expand Down

0 comments on commit 0008c7e

Please sign in to comment.