Jelajahi Sumber

fix: updating the array using push in zustand does not actually trigger component updates

Jiacheng Dong 1 tahun lalu
induk
melakukan
1d42e955fc
1 mengubah file dengan 4 tambahan dan 2 penghapusan
  1. 4 2
      app/store/chat.ts

+ 4 - 2
app/store/chat.ts

@@ -317,8 +317,10 @@ export const useChatStore = create<ChatStore>()(
             botMessage.streaming = false;
             botMessage.streaming = false;
             userMessage.isError = !isAborted;
             userMessage.isError = !isAborted;
             botMessage.isError = !isAborted;
             botMessage.isError = !isAborted;
-
-            set(() => ({}));
+            get().updateCurrentSession((session) => {
+              session.messages = session.messages.concat();
+            });
+            // set(() => ({}));
             ChatControllerPool.remove(
             ChatControllerPool.remove(
               sessionIndex,
               sessionIndex,
               botMessage.id ?? messageIndex,
               botMessage.id ?? messageIndex,