mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
refactor(Chat, Messages): simplify maxWidth calculations and remove unused showAssistants variable
This commit is contained in:
parent
9dc9b0280e
commit
c6e574d080
@ -26,7 +26,7 @@ interface Props {
|
||||
|
||||
const Chat: FC<Props> = (props) => {
|
||||
const { assistant } = useAssistant(props.assistant.id)
|
||||
const { topicPosition, messageStyle, showAssistants } = useSettings()
|
||||
const { topicPosition, messageStyle } = useSettings()
|
||||
const { showTopics } = useShowTopics()
|
||||
const { isMultiSelectMode } = useChatContext(props.activeTopic)
|
||||
|
||||
@ -36,10 +36,9 @@ const Chat: FC<Props> = (props) => {
|
||||
|
||||
const maxWidth = useMemo(() => {
|
||||
const showRightTopics = showTopics && topicPosition === 'right'
|
||||
const minusAssistantsWidth = showAssistants ? `- var(--assistants-width) - var(--scrollbar-width)` : ''
|
||||
const minusRightTopicsWidth = showRightTopics ? `- var(--assistants-width) - var(--scrollbar-width)` : ''
|
||||
return `calc(100vw - var(--sidebar-width) ${minusAssistantsWidth} ${minusRightTopicsWidth})`
|
||||
}, [showAssistants, showTopics, topicPosition])
|
||||
const minusRightTopicsWidth = showRightTopics ? `- var(--assistants-width)` : ''
|
||||
return `calc(100vw - var(--sidebar-width) - var(--assistants-width) ${minusRightTopicsWidth})`
|
||||
}, [showTopics, topicPosition])
|
||||
|
||||
useHotkeys('esc', () => {
|
||||
contentSearchRef.current?.disable()
|
||||
|
||||
@ -86,13 +86,6 @@ const Messages: React.FC<MessagesProps> = ({ assistant, topic, setActiveTopic, o
|
||||
setHasMore(messages.length > displayCount)
|
||||
}, [messages, displayCount])
|
||||
|
||||
const maxWidth = useMemo(() => {
|
||||
const showRightTopics = showTopics && topicPosition === 'right'
|
||||
const minusAssistantsWidth = showAssistants ? `- var(--assistants-width) - var(--scrollbar-width)` : ''
|
||||
const minusRightTopicsWidth = showRightTopics ? `- var(--assistants-width) - var(--scrollbar-width)` : ''
|
||||
return `calc(100vw - var(--sidebar-width) ${minusAssistantsWidth} ${minusRightTopicsWidth})`
|
||||
}, [showAssistants, showTopics, topicPosition])
|
||||
|
||||
const scrollToBottom = useCallback(() => {
|
||||
if (scrollContainerRef.current) {
|
||||
requestAnimationFrame(() => {
|
||||
@ -277,11 +270,7 @@ const Messages: React.FC<MessagesProps> = ({ assistant, topic, setActiveTopic, o
|
||||
<Container
|
||||
id="messages"
|
||||
ref={scrollContainerRef}
|
||||
style={{
|
||||
position: 'relative',
|
||||
maxWidth,
|
||||
paddingTop: showPrompt ? 10 : 0
|
||||
}}
|
||||
style={{ position: 'relative', paddingTop: showPrompt ? 10 : 0 }}
|
||||
key={assistant.id}
|
||||
onScroll={handleScrollPosition}
|
||||
$right={topicPosition === 'left'}>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user