Skip to content

使用setMessages恢复对话的时候需要修改idRef #467

Closed
@gliheng

Description

@gliheng

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @ant-design/[email protected] for the project I'm working on.

我使用setMessages恢复之前的对话session。然而idRef无法修改,始终从0开始导致出现重复。我想这个暴露给用户的setMessages方法需要修改idRef。以避免重复的id!

Here is the diff that solved my problem:

diff --git a/node_modules/@ant-design/x/es/useXChat/index.js b/node_modules/@ant-design/x/es/useXChat/index.js
index fd43782..2b159b3 100644
--- a/node_modules/@ant-design/x/es/useXChat/index.js
+++ b/node_modules/@ant-design/x/es/useXChat/index.js
@@ -147,6 +147,9 @@ export default function useXChat(config) {
     onRequest,
     messages,
     parsedMessages,
-    setMessages
+    setMessages(messages) {
+      setMessages(messages);
+      idRef.current = messages.length;
+    },
   };
 }
\ No newline at end of file

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions