mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +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 { useQuery } from '@tanstack/react-query';
|
||||||
import { useGit } from './useGit';
|
import { useGit } from './useGit';
|
||||||
|
|
||||||
|
interface GitFetchResult {
|
||||||
|
defaultBranch: string | null;
|
||||||
|
fetchHead: string | null;
|
||||||
|
fetchHeadDescription: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export function useGitFetch(dir: string | undefined) {
|
export function useGitFetch(dir: string | undefined) {
|
||||||
const { git } = useGit();
|
const { git } = useGit();
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['git-fetch', dir],
|
queryKey: ['git-fetch', dir],
|
||||||
queryFn: async (): Promise<void> => {
|
queryFn: async (): Promise<GitFetchResult> => {
|
||||||
if (!dir) {
|
if (dir) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await git.fetch({
|
return await git.fetch({
|
||||||
dir,
|
dir,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fetch failed, but don't throw - just log and return null
|
// Fetch failed, but don't throw - just log and return null
|
||||||
console.warn('Git fetch failed:', error);
|
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,
|
enabled: !!dir,
|
||||||
refetchInterval: 60000, // Fetch every 60 seconds
|
refetchInterval: 60000, // Fetch every 60 seconds
|
||||||
|
|||||||
Reference in new issue
Block a user