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