Unverified Commit daa1e9ed authored by Xiang Jaywhen's avatar Xiang Jaywhen Committed by GitHub

fix: Ask-AI history list reversed when loading answer (#1301)

parent 008d6a0c
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: 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: Props) => {
<Icon.Loader className="w-5 h-auto animate-spin" />
</p>
)}
{reverse(historyList).map((history, index) => (
{historyList.map((history, index) => (
<div key={index} className="w-full flex flex-col justify-start items-start mt-4 space-y-2">
<div className="w-full flex flex-row justify-start items-start pr-6">
<span className="word-break rounded shadow px-3 py-2 opacity-80 bg-gray-100 dark:bg-zinc-700">{history.question}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment