Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

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

Xiang Jaywhendaa1e9edfb17
diff --git a/web/src/components/AskAIDialog.tsx b/web/src/components/AskAIDialog.tsx
index d0b9a99bc..084dd6162 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: 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>