mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
turn repo and status loaders to actions to control when they run (#6262)
This commit is contained in:
parent
ee6a4246b7
commit
1a96880bca
@ -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]);
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user