Skip to content

Commit

Permalink
fix(web): reverse array bug (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeezQ authored Feb 14, 2023
1 parent 60c55ed commit dc34c2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/src/pages/app/functions/mods/ConsolePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ function ConsolePanel() {
},
);

const list = logControllerGetLogsQuery.data?.data?.list || [];
// reverse will change the original array, so we need to clone it first
const cloneReverseArray = [...list].reverse();

return (
<Panel className="flex-1 max-h-[200px]">
<Panel.Header title="Console"></Panel.Header>
Expand All @@ -37,8 +41,8 @@ function ConsolePanel() {
<Center>
<Spinner />
</Center>
) : logControllerGetLogsQuery.data?.data?.list?.length ? (
logControllerGetLogsQuery.data?.data?.list?.reverse().map((item: any) => {
) : cloneReverseArray.length > 0 ? (
cloneReverseArray.map((item: any) => {
return (
<div key={item._id} className="flex ">
<span className=" text-slate-500 min-w-[160px]">
Expand Down

0 comments on commit dc34c2a

Please sign in to comment.