Skip to content

Commit d6502c0

Browse files
committed
refactor: Simplify and strengthen code
1 parent a0d6a83 commit d6502c0

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

packages/cozy-dataproxy-lib/src/components/Conversations/ChatAssistantItem.jsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
77
import ChatItem from './ChatItem'
88
import Sources from './Sources/Sources'
99

10-
const ChatAssistantItem = ({ className, id, label, sources, ...props }) => {
10+
const ChatAssistantItem = ({ id, sources, ...props }) => {
1111
const { t } = useI18n()
1212
// need memo to avoid rendering it everytime
1313
const icon = useMemo(() => <Icon icon={AssistantIcon} size={32} />, [])
1414

1515
return (
1616
<>
17-
<ChatItem
18-
{...props}
19-
className={className}
20-
icon={icon}
21-
name={t('assistant.name')}
22-
label={label}
23-
/>
17+
<ChatItem {...props} icon={icon} name={t('assistant.name')} />
2418
{sources?.length > 0 && <Sources messageId={id} sources={sources} />}
2519
</>
2620
)

packages/cozy-dataproxy-lib/src/components/Conversations/ChatConversation.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ChatConversation = ({ conversation, myself }) => {
3131

3232
return (
3333
<div ref={listRef}>
34-
{conversation?.messages.map((message, idx) => {
34+
{conversation?.messages?.map((message, idx) => {
3535
if (message.role === 'user') {
3636
return (
3737
<ChatUserItem

packages/cozy-dataproxy-lib/src/components/ResultMenu/ResultMenuContent.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ import { useSearch } from '../Search/SearchProvider'
1616
const SearchResult = () => {
1717
const { isLoading, results, selectedIndex, searchValue } = useSearch()
1818

19-
if (isLoading && !results?.length)
19+
if (isLoading && !results?.length) {
2020
return (
2121
<>
2222
<ListItemSkeleton hasSecondary />
2323
<ListItemSkeleton hasSecondary />
2424
<ListItemSkeleton hasSecondary />
2525
</>
2626
)
27+
}
2728

2829
return results.map((result, idx) => (
2930
<ResultMenuItem

0 commit comments

Comments
 (0)