Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
daa1e9ed
Unverified
Commit
daa1e9ed
authored
Mar 07, 2023
by
Xiang Jaywhen
Committed by
GitHub
Mar 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Ask-AI history list reversed when loading answer (#1301)
parent
008d6a0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
AskAIDialog.tsx
web/src/components/AskAIDialog.tsx
+2
-3
No files found.
web/src/components/AskAIDialog.tsx
View file @
daa1e9ed
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) => {
...
@@ -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) => {
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment