Skip to content

Commit

Permalink
fix: sort console timeline by time
Browse files Browse the repository at this point in the history
Timeline service sorts by ID, so console now resorts events for presentation.
  • Loading branch information
matt2e committed Dec 10, 2024
1 parent d8fb7f3 commit 725acab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/console/src/api/timeline/use-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useVisibility } from '../../hooks/use-visibility'
import type { Event } from '../../protos/xyz/block/ftl/timeline/v1/event_pb'
import { TimelineService } from '../../protos/xyz/block/ftl/timeline/v1/timeline_connect'
import { type GetTimelineRequest_Filter, GetTimelineRequest_Order } from '../../protos/xyz/block/ftl/timeline/v1/timeline_pb'
import { compareTimestamps } from '../../utils/date.utils'

const timelineKey = 'timeline'
const maxTimelineEntries = 1000
Expand Down Expand Up @@ -49,7 +50,7 @@ export const useTimeline = (isStreaming: boolean, filters: GetTimelineRequest_Fi
console.debug('timeline-response:', response)
if (response.events) {
queryClient.setQueryData<Event[]>(queryKey, (prev = []) => {
return [...response.events, ...prev].slice(0, maxTimelineEntries)
return [...response.events, ...prev].sort((a, b) => compareTimestamps(b.timestamp, a.timestamp)).slice(0, maxTimelineEntries)
})
}
}
Expand Down

0 comments on commit 725acab

Please sign in to comment.