From 96487827bc64806f69bf9dee60469f4cf1f0ff0f Mon Sep 17 00:00:00 2001 From: James Gatz Date: Mon, 31 Oct 2022 12:32:23 +0100 Subject: [PATCH] fix git clone not showing the document in project view (#5358) * revalidate the data when cloning a document * properly redirect to a design document --- packages/insomnia/src/ui/redux/modules/git.tsx | 4 +++- packages/insomnia/src/ui/routes/actions.tsx | 7 +------ packages/insomnia/src/ui/routes/project.tsx | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/insomnia/src/ui/redux/modules/git.tsx b/packages/insomnia/src/ui/redux/modules/git.tsx index 8be3e6c3f..98a847cd0 100644 --- a/packages/insomnia/src/ui/redux/modules/git.tsx +++ b/packages/insomnia/src/ui/redux/modules/git.tsx @@ -153,8 +153,9 @@ const noDocumentFound = (gitRepo: GitRepository) => { /** * Clone a git repository * */ -export const cloneGitRepository = ({ createFsClient }: { +export const cloneGitRepository = ({ createFsClient, onComplete }: { createFsClient: () => git.PromiseFsClient; + onComplete?: () => void; }) => { return (dispatch: any, getState: () => RootState) => { // TODO: in the future we should ask which project to clone into...? @@ -291,6 +292,7 @@ export const cloneGitRepository = ({ createFsClient }: { await db.flushChanges(bufferId); dispatch(loadStop()); trackSegmentEvent(SegmentEvent.vcsSyncComplete, { ...vcsSegmentEventProperties('git', 'clone'), providerName }); + onComplete?.(); }, }); }, diff --git a/packages/insomnia/src/ui/routes/actions.tsx b/packages/insomnia/src/ui/routes/actions.tsx index ee80815bd..9b02ed984 100644 --- a/packages/insomnia/src/ui/routes/actions.tsx +++ b/packages/insomnia/src/ui/routes/actions.tsx @@ -90,12 +90,7 @@ export const createNewWorkspaceAction: ActionFunction = async ({ await models.workspaceMeta.getOrCreateByParentId(workspace._id); await database.flushChanges(flushId); - if (session.isLoggedIn() && isRemoteProject(project)) { - if (!isCollection(workspace)) { - // Don't initialize and mark for sync unless we're in a collection - return; - } - + if (session.isLoggedIn() && isRemoteProject(project) && isCollection(workspace)) { const vcs = getVCS(); if (vcs) { initializeLocalBackendProjectAndMarkForSync({ diff --git a/packages/insomnia/src/ui/routes/project.tsx b/packages/insomnia/src/ui/routes/project.tsx index a3b60a517..71cb6dbff 100644 --- a/packages/insomnia/src/ui/routes/project.tsx +++ b/packages/insomnia/src/ui/routes/project.tsx @@ -339,8 +339,8 @@ const ProjectRoute: FC = () => { }, [dispatch, revalidate]); const importFromGit = useCallback(() => { - dispatch(cloneGitRepository({ createFsClient: MemClient.createClient })); - }, [dispatch]); + dispatch(cloneGitRepository({ createFsClient: MemClient.createClient, onComplete: revalidate })); + }, [dispatch, revalidate]); return (