Add back a simple useGitFetch hook

This commit is contained in:
Alex Gleason committed 2025-12-24 21:38:57 -06:00
1 parent a9c1922e51
commit e599f76787
5 files changed
+43 -9

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { useQuery } from '@tanstack/react-query';
import { useGit } from './useGit';
export function useGitFetch(dir: string | undefined) {
const { git } = useGit();
const query = useQuery({
queryKey: ['git-fetch', dir],
queryFn: async (): Promise<void> => {
if (!dir) {
return;
}
try {
try {
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;
}
},
enabled: !!dir,
refetchInterval: 60000, // Fetch every 60 seconds
staleTime: 30000, // Consider data stale after 30 seconds
retry: false, // Don't retry on failure
});
return query;
}