mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 18:10:26 +08:00
fix: history topic message block is empty
* Added useEffect to dispatch loadTopicMessagesThunk when the topic is available * Integrated useAppDispatch for state management
This commit is contained in:
parent
011b9dca33
commit
69ccd2aa32
@ -7,10 +7,12 @@ import { getAssistantById } from '@renderer/services/AssistantService'
|
|||||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
||||||
import { isGenerating, locateToMessage } from '@renderer/services/MessagesService'
|
import { isGenerating, locateToMessage } from '@renderer/services/MessagesService'
|
||||||
import NavigationService from '@renderer/services/NavigationService'
|
import NavigationService from '@renderer/services/NavigationService'
|
||||||
|
import { useAppDispatch } from '@renderer/store'
|
||||||
|
import { loadTopicMessagesThunk } from '@renderer/store/thunk/messageThunk'
|
||||||
import { Topic } from '@renderer/types'
|
import { Topic } from '@renderer/types'
|
||||||
import { Button, Divider, Empty } from 'antd'
|
import { Button, Divider, Empty } from 'antd'
|
||||||
import { t } from 'i18next'
|
import { t } from 'i18next'
|
||||||
import { FC } from 'react'
|
import { FC, useEffect } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
import { default as MessageItem } from '../../home/Messages/Message'
|
import { default as MessageItem } from '../../home/Messages/Message'
|
||||||
@ -23,6 +25,11 @@ const TopicMessages: FC<Props> = ({ topic, ...props }) => {
|
|||||||
const navigate = NavigationService.navigate!
|
const navigate = NavigationService.navigate!
|
||||||
const { handleScroll, containerRef } = useScrollPosition('TopicMessages')
|
const { handleScroll, containerRef } = useScrollPosition('TopicMessages')
|
||||||
const { messageStyle } = useSettings()
|
const { messageStyle } = useSettings()
|
||||||
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
topic && dispatch(loadTopicMessagesThunk(topic.id))
|
||||||
|
}, [dispatch, topic])
|
||||||
|
|
||||||
const isEmpty = (topic?.messages || []).length === 0
|
const isEmpty = (topic?.messages || []).length === 0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user