Skip to content

Commit

Permalink
add get track data with enabled option
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanprog committed Apr 24, 2024
1 parent 0a48f1c commit 753deac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/frontend/hooks/server/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
useQueryClient,
useMutation,
useSuspenseQuery,
useQuery,
} from '@tanstack/react-query';
import {useProject} from './projects';
import {TrackValue} from '@mapeo/schema';
Expand Down Expand Up @@ -33,6 +34,19 @@ export function useTracksQuery() {
});
}

export function useTrackWithEnableOptionQuery(docId?: string) {
const project = useProject();
return useQuery({
queryKey: [TRACK_KEY],
enabled: !!docId,
queryFn: async () => {
if (!docId) return;
if (!project) throw new Error('Project instance does not exist');
return project.track.getByDocId(docId);
},
});
}

export function useTrackQuery(docId: string) {
const project = useProject();
return useSuspenseQuery({
Expand Down

0 comments on commit 753deac

Please sign in to comment.