From daa1e9edfb17e5932c75d5e8f586a10f7e09be39 Mon Sep 17 00:00:00 2001 From: Xiang Jaywhen Date: Tue, 7 Mar 2023 19:36:18 +0800 Subject: [PATCH] fix: Ask-AI history list reversed when loading answer (#1301) --- web/src/components/AskAIDialog.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/src/components/AskAIDialog.tsx b/web/src/components/AskAIDialog.tsx index d0b9a99b..084dd616 100644 --- a/web/src/components/AskAIDialog.tsx +++ b/web/src/components/AskAIDialog.tsx @@ -1,5 +1,4 @@ import { Button, Textarea } from "@mui/joy"; -import { reverse } from "lodash-es"; import { useEffect, useState } from "react"; import * as api from "../helpers/api"; import useLoading from "../hooks/useLoading"; @@ -60,11 +59,11 @@ const AskAIDialog: React.FC = (props: Props) => { data: { data: answer }, } = await api.postChatCompletion(question); setHistoryList([ - ...historyList, { question, answer: answer.replace(/^\n\n/, ""), }, + ...historyList, ]); }; @@ -86,7 +85,7 @@ const AskAIDialog: React.FC = (props: Props) => {

)} - {reverse(historyList).map((history, index) => ( + {historyList.map((history, index) => (
{history.question}