Skip to content

Commit

Permalink
feat(next/web): add timelineAfter param
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Mar 12, 2024
1 parent 05f6e1e commit 3e43ece
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions next/web/src/App/Admin/Tickets/Ticket/timeline-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import { ReplySchema } from '@/api/reply';
import { fetchTicketReplies, fetchTicketOpsLogs, OpsLog } from '@/api/ticket';
import { useCurrentRef } from '@/utils/useCurrentRef';

function getCursor() {
const search = new URLSearchParams(window.location.search);
return search.get('timelineAfter') || undefined;
}

export function useTicketReplies(ticketId?: string) {
const { data, fetchNextPage, refetch } = useInfiniteQuery({
queryKey: ['TicketReplies', ticketId],
queryFn: ({ pageParam }) => {
return fetchTicketReplies(ticketId || '', {
cursor: pageParam,
cursor: pageParam || getCursor(),
deleted: true,
pageSize: 1000,
});
Expand Down Expand Up @@ -77,7 +82,7 @@ export function useTicketOpsLogs(ticketId?: string) {
queryKey: ['TicketOpsLogs', ticketId],
queryFn: ({ pageParam }) => {
return fetchTicketOpsLogs(ticketId || '', {
cursor: pageParam,
cursor: pageParam || getCursor(),
pageSize: 1000,
});
},
Expand Down

0 comments on commit 3e43ece

Please sign in to comment.