Skip to content

Commit

Permalink
properly log DOIs on all file listing operations (#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb authored Aug 30, 2024
1 parent b56aad2 commit 7c82c1f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/modules/_hooks/src/datafiles/useFileListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useInfiniteQuery } from '@tanstack/react-query';
import apiClient from '../apiClient';
import { AxiosError } from 'axios';
import { useSearchParams } from 'react-router-dom';
import { useDoiContext } from './publications';

export type TFileListing = {
system: string;
Expand Down Expand Up @@ -31,13 +32,17 @@ async function getFileListing(
page: number = 0,
nextPageToken: string | undefined,
queryString: string | undefined,
doi: string | undefined,
{ signal }: { signal: AbortSignal }
) {
const offset = page * limit;

const res = await apiClient.get<FileListingResponse>(
`/api/datafiles/${api}/${scheme}/listing/${system}/${path}`,
{ signal, params: { offset, limit, nextPageToken, q: queryString } }
{
signal,
params: { offset, limit, nextPageToken, q: queryString, doi: doi },
}
);
return res.data;
}
Expand Down Expand Up @@ -68,6 +73,7 @@ function useFileListing({
}: TFileListingHookArgs) {
const [searchParams] = useSearchParams();
const queryString = searchParams.get('q') ?? searchTerm;
const doi = useDoiContext();
return useInfiniteQuery<
FileListingResponse,
AxiosError<{ message?: string }>
Expand All @@ -91,6 +97,7 @@ function useFileListing({
(pageParam as TFileListingPageParam).page,
(pageParam as TFileListingPageParam).nextPageToken,
queryString ?? undefined,
doi ?? undefined,
{
signal,
}
Expand Down

0 comments on commit 7c82c1f

Please sign in to comment.