From 1a96880bcaf34e0fa6e98189ca23236550e54ee5 Mon Sep 17 00:00:00 2001 From: James Gatz Date: Fri, 11 Aug 2023 16:01:57 +0200 Subject: [PATCH] turn repo and status loaders to actions to control when they run (#6262) --- .../components/dropdowns/git-sync-dropdown.tsx | 16 ++++++++++------ packages/insomnia/src/ui/index.tsx | 4 ++-- packages/insomnia/src/ui/routes/git-actions.tsx | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/insomnia/src/ui/components/dropdowns/git-sync-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/git-sync-dropdown.tsx index a91b790b6..8c6f4c2a8 100644 --- a/packages/insomnia/src/ui/components/dropdowns/git-sync-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/git-sync-dropdown.tsx @@ -71,9 +71,11 @@ export const GitSyncDropdown: FC = ({ 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 = ({ 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]); diff --git a/packages/insomnia/src/ui/index.tsx b/packages/insomnia/src/ui/index.tsx index db89ebc75..3370a31db 100644 --- a/packages/insomnia/src/ui/index.tsx +++ b/packages/insomnia/src/ui/index.tsx @@ -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', diff --git a/packages/insomnia/src/ui/routes/git-actions.tsx b/packages/insomnia/src/ui/routes/git-actions.tsx index e3547938a..10994a8c1 100644 --- a/packages/insomnia/src/ui/routes/git-actions.tsx +++ b/packages/insomnia/src/ui/routes/git-actions.tsx @@ -52,7 +52,7 @@ export type GitRepoLoaderData = errors: string[]; }; -export const gitRepoLoader: LoaderFunction = async ({ +export const gitRepoAction: ActionFunction = async ({ params, }): Promise => { try { @@ -1271,7 +1271,7 @@ export interface GitStatusResult { }; } -export const gitStatusLoader: LoaderFunction = async ({ +export const gitStatusAction: ActionFunction = async ({ params, }): Promise => { const { workspaceId } = params;