turn repo and status loaders to actions to control when they run (#6262)

This commit is contained in:
James Gatz 2023-08-11 16:01:57 +02:00 committed by GitHub
parent ee6a4246b7
commit 1a96880bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -71,9 +71,11 @@ export const GitSyncDropdown: FC<Props> = ({ className, gitRepository, isInsomni
gitRepoDataFetcher.state === 'idle' &&
!gitRepoDataFetcher.data
) {
gitRepoDataFetcher.load(
`/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/git/repo`
);
console.log('[git:fetcher] Fetching git repo data');
gitRepoDataFetcher.submit({}, {
action: `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/git/repo`,
method: 'post',
});
}
}, [
gitRepoDataFetcher,
@ -89,9 +91,11 @@ export const GitSyncDropdown: FC<Props> = ({ className, gitRepository, isInsomni
useEffect(() => {
if (shouldFetchGitRepoStatus) {
gitStatusFetcher.load(
`/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/git/status`
);
console.log('[git:fetcher] Fetching git repo status');
gitStatusFetcher.submit({}, {
action: `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/git/status`,
method: 'post',
});
}
}, [gitStatusFetcher, organizationId, projectId, shouldFetchGitRepoStatus, workspaceId]);

View File

@ -410,7 +410,7 @@ const router = createMemoryRouter(
children: [
{
path: 'status',
loader: async (...args) => (await import('./routes/git-actions')).gitStatusLoader(...args),
action: async (...args) => (await import('./routes/git-actions')).gitStatusAction(...args),
},
{
path: 'changes',
@ -459,7 +459,7 @@ const router = createMemoryRouter(
},
{
path: 'repo',
loader: async (...args) => (await import('./routes/git-actions')).gitRepoLoader(...args),
action: async (...args) => (await import('./routes/git-actions')).gitRepoAction(...args),
},
{
path: 'update',

View File

@ -52,7 +52,7 @@ export type GitRepoLoaderData =
errors: string[];
};
export const gitRepoLoader: LoaderFunction = async ({
export const gitRepoAction: ActionFunction = async ({
params,
}): Promise<GitRepoLoaderData> => {
try {
@ -1271,7 +1271,7 @@ export interface GitStatusResult {
};
}
export const gitStatusLoader: LoaderFunction = async ({
export const gitStatusAction: ActionFunction = async ({
params,
}): Promise<GitStatusResult> => {
const { workspaceId } = params;