From 0b0bd0ac045783b18dc31a7838b3aec4536817ee Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 8 Mar 2024 20:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BD=93=E9=AA=8C:=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E8=A1=A8=E5=8D=95=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/FormStore.js | 13 +++++++++++++ src/views/ChatHistory.jsx | 14 ++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/stores/FormStore.js diff --git a/src/stores/FormStore.js b/src/stores/FormStore.js new file mode 100644 index 0000000..7fef332 --- /dev/null +++ b/src/stores/FormStore.js @@ -0,0 +1,13 @@ +import { create } from 'zustand'; +import { RealTimeAPI } from '@/lib/realTimeAPI'; +import { olog, isEmpty } from '@/utils/utils'; +import { receivedMsgTypeMapped, handleNotification } from '@/lib/msgUtils'; +import { fetchConversationsList, fetchTemplates, fetchMessages } from '@/actions/ConversationActions'; +import { devtools } from 'zustand/middleware'; +import { WS_URL } from '@/config'; + +export const useFormStore = create(devtools((set, get) => ({ + chatHistory: {}, + setChatHistory: (chatHistory) => set({ chatHistory }), +}))); +export default useFormStore; diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx index 31a0585..4cfcfa1 100644 --- a/src/views/ChatHistory.jsx +++ b/src/views/ChatHistory.jsx @@ -5,6 +5,8 @@ import { StarFilled, ZoomInOutlined, StarOutlined, SearchOutlined } from '@ant-d import { ChatList, ChatItem, MessageBox } from 'react-chat-elements'; import { fetchConversationsList, fetchMessages } from '@/actions/ConversationActions'; import { isEmpty } from '@/utils/utils'; +import useFormStore from '@/stores/FormStore'; +import { useShallow } from 'zustand/react/shallow'; const { Sider, Content, Header, Footer } = Layout; const { Search } = Input; @@ -63,7 +65,7 @@ const data = [ ]; // eslint-disable-next-line react/display-name -const SearchForm = memo(function ({ onSubmit }) { +const SearchForm = memo(function ({ initialValues, onSubmit }) { const [form] = Form.useForm(); function handleSubmit(values) { onSubmit?.(values); @@ -72,7 +74,7 @@ const SearchForm = memo(function ({ onSubmit }) {
[state.chatHistory, state.setChatHistory]), + ) + const handleSubmit = useCallback((values) => { setFormValues({ ...values }); @@ -290,7 +296,7 @@ function ChatHistory() { )); return ( <> - +