Query must return something in useGitFetch

This commit is contained in:
Alex Gleason committed 2025-12-25 00:14:09 -06:00
1 parent 1804436565
commit 2f2957435a
1 file changed
+15 -12
+15 -12
View File
@@ -1,31 +1,34 @@
import { useQuery } from '@tanstack/react-query';
import { useGit } from './useGit';
interface GitFetchResult {
defaultBranch: string | null;
fetchHead: string | null;
fetchHeadDescription: string | null;
}
export function useGitFetch(dir: string | undefined) {
const { git } = useGit();
const query = useQuery({
queryKey: ['git-fetch', dir],
queryFn: async (): Promise<void> => {
if (!dir) {
return;
}
try {
queryFn: async (): Promise<GitFetchResult> => {
if (dir) {
try {
await git.fetch({
return await git.fetch({
dir,
});
} catch (error) {
// Fetch failed, but don't throw - just log and return null
console.warn('Git fetch failed:', error);
return;
}
} catch (error) {
console.error('Error during git fetch:', error);
return;
}
return {
defaultBranch: null,
fetchHead: null,
fetchHeadDescription: null,
};
},
enabled: !!dir,
refetchInterval: 60000, // Fetch every 60 seconds