Răsfoiți Sursa

fix: backward pagination on initial load

Soham Parekh 3 ani în urmă
părinte
comite
5f736ffd4d

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/LogsSection.tsx

@@ -138,7 +138,7 @@ const LogsSection: React.FC<Props> = ({
           <span className="line-timestamp">
             {dayjs(log.timestamp).format("MMM D, YYYY HH:mm:ss")}
           </span>
-          {log.line.map((ansi, j) => {
+          {log.line?.map((ansi, j) => {
             if (ansi.clearLine) {
               return null;
             }

+ 5 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/useAgentLogs.ts

@@ -213,6 +213,10 @@ export const useLogs = (
           res.data.logs?.filter(Boolean).map((logLine: any) => logLine.line)
         );
 
+        if (direction === Direction.backward) {
+          newLogs.reverse();
+        }
+
         return {
           logs: newLogs,
           previousCursor: res.data.backward_continue_time,
@@ -235,7 +239,7 @@ export const useLogs = (
     const { logs: initialLogs, previousCursor, nextCursor } = await queryLogs(
       twoWeeksAgo.toISOString(),
       endDate.toISOString(),
-      Direction.forward
+      Direction.backward
     );
 
     setPaginationInfo({