mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Query must return something in useGitFetch
This commit is contained in:
1 file changed
+15
-12
+15
-12
@@ -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
|
||||
|
||||
Reference in new issue
Block a user