fix(ui): push log sort toggle server-side
Reversing logStream.items client-side breaks across infinite-scroll pages. Passing sort='asc'/'desc' into the query key and URL triggers a fresh first-page fetch in the selected order.
This commit is contained in:
@@ -165,6 +165,7 @@ export interface UseInfiniteApplicationLogsArgs {
|
||||
sources?: string[]; // multi-select, server-side OR
|
||||
levels?: string[]; // multi-select, server-side OR
|
||||
exchangeId?: string;
|
||||
sort?: 'asc' | 'desc';
|
||||
isAtTop: boolean;
|
||||
pageSize?: number;
|
||||
}
|
||||
@@ -189,6 +190,7 @@ export function useInfiniteApplicationLogs(
|
||||
const sourcesParam = sortedSources.join(',');
|
||||
const levelsParam = sortedLevels.join(',');
|
||||
const pageSize = args.pageSize ?? 100;
|
||||
const sort = args.sort ?? 'desc';
|
||||
|
||||
return useInfiniteStream<LogEntryResponse>({
|
||||
queryKey: [
|
||||
@@ -202,6 +204,7 @@ export function useInfiniteApplicationLogs(
|
||||
fromIso ?? '',
|
||||
toIso ?? '',
|
||||
pageSize,
|
||||
sort,
|
||||
],
|
||||
enabled: !!args.application && !!selectedEnv,
|
||||
isAtTop: args.isAtTop,
|
||||
@@ -217,7 +220,7 @@ export function useInfiniteApplicationLogs(
|
||||
if (toIso) qp.set('to', toIso);
|
||||
if (cursor) qp.set('cursor', cursor);
|
||||
qp.set('limit', String(pageSize));
|
||||
qp.set('sort', 'desc');
|
||||
qp.set('sort', sort);
|
||||
|
||||
const res = await fetch(
|
||||
`${config.apiBaseUrl}/environments/${encodeURIComponent(selectedEnv ?? '')}/logs?${qp}`,
|
||||
|
||||
Reference in New Issue
Block a user