mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: Ask-AI history list reversed when loading answer (#1301)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Button, Textarea } from "@mui/joy";
|
import { Button, Textarea } from "@mui/joy";
|
||||||
import { reverse } from "lodash-es";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import * as api from "../helpers/api";
|
import * as api from "../helpers/api";
|
||||||
import useLoading from "../hooks/useLoading";
|
import useLoading from "../hooks/useLoading";
|
||||||
@@ -60,11 +59,11 @@ const AskAIDialog: React.FC<Props> = (props: Props) => {
|
|||||||
data: { data: answer },
|
data: { data: answer },
|
||||||
} = await api.postChatCompletion(question);
|
} = await api.postChatCompletion(question);
|
||||||
setHistoryList([
|
setHistoryList([
|
||||||
...historyList,
|
|
||||||
{
|
{
|
||||||
question,
|
question,
|
||||||
answer: answer.replace(/^\n\n/, ""),
|
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" />
|
<Icon.Loader className="w-5 h-auto animate-spin" />
|
||||||
</p>
|
</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 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">
|
<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>
|
<span className="word-break rounded shadow px-3 py-2 opacity-80 bg-gray-100 dark:bg-zinc-700">{history.question}</span>
|
||||||
|
Reference in New Issue
Block a user