Skip to content

Commit

Permalink
3028: Fixed Code Complexity and Correct Translations
Browse files Browse the repository at this point in the history
  • Loading branch information
hannaseithe committed Feb 18, 2025
1 parent 252b95a commit 07c4bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@
},
"chat": {
"de": {
"botIcon": "Chat Bot",
"botIcon": "Chatbot",
"button": "Chat (beta)",
"conversationTitle": "Bitte gib deine Frage in das Textfeld ein.",
"conversationText": "Du kannst alles fragen, von lokalen Informationen bis hin zu spezifischen Anfragen bezüglich deiner Situation.",
"dataSecurity": "Datenschutz und Sicherheit: Deine Privatsphäre ist uns sehr wichtig. Alle Gespräche werden vertraulich behandelt und deine Daten werden sicher verarbeitet. Mehr Informationen zum Datenschutz findest du in unseren Datenschutzrichtlinien.",
"errorMessage": "Es ist ein Fehler bei der Kommunikation aufgetreten.",
"header": "{{appName}} Chat Support",
"humanIcon": "(menschlicher) Berater",
"humanIcon": "Berater*in",
"initialMessage": "Deine Chatanfrage wurde gesendet. Die Berater*in beantwortet deine Nachricht so schnell wie möglich.",
"inputLabel": "Meine Frage:",
"inputPlaceholder": "Ich möchte wissen...",
Expand Down Expand Up @@ -382,14 +382,14 @@
"user": "Εσείς"
},
"en": {
"chatIcon": "Chat Bot",
"chatIcon": "Chatbot",
"button": "Chat (beta)",
"conversationTitle": "Please enter your question in the text field.",
"conversationText": "You can ask anything from local information to specific requests regarding your situation.",
"dataSecurity": "Data protection and security: Your privacy is very important to us. All conversations are treated confidentially and your data is processed securely. You can find more information on data protection in our privacy policy.",
"errorMessage": "An error has occurred during communication.",
"header": "{{appName}} Chat Support",
"humanIcon": "(human) Advisor",
"humanIcon": "Advisor",
"initialMessage": "Your chat request has been sent. The advisor will answer your message as soon as possible.",
"inputLabel": "My question:",
"inputPlaceholder": "I would like to know...",
Expand Down
17 changes: 9 additions & 8 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 @@ -81,14 +89,7 @@ const ChatConversation = ({ messages, hasError, className }: ChatConversationPro
<>
{!hasError && <InitialMessage>{t('initialMessage')}</InitialMessage>}
{messages.map((message, index) => (
<ChatMessage
message={message}
key={message.id}
showIcon={
messages[index - 1]?.userIsAuthor !== message.userIsAuthor ||
messages[index - 1]?.isAutomaticAnswer !== message.isAutomaticAnswer
}
/>
<ChatMessage message={message} key={message.id} showIcon={shouldShowIcon(index, message, messages)} />

Check notice on line 92 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} />
<div ref={messagesEndRef} />
Expand Down

0 comments on commit 07c4bbc

Please sign in to comment.