From 8f790bf962d5c3b2dff7712265c9b1ccafd57388 Mon Sep 17 00:00:00 2001 From: Curry Yang <163384738+CurryYangxx@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:27:42 +0800 Subject: [PATCH] feat(sync): support offline commit- [INS-4226] (#7811) * feat(sync): support offline commit --- .../ui/components/dropdowns/sync-dropdown.tsx | 1 - .../src/ui/routes/remote-collections.tsx | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx index 042c3b957..8c87665f2 100644 --- a/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx @@ -90,7 +90,6 @@ export const SyncDropdown: FC = ({ gitSyncEnabled }) => { historyCount: 0, history: [], syncItems: [], - remoteBackendProjects: [], compare: { ahead: 0, behind: 0 }, }; diff --git a/packages/insomnia/src/ui/routes/remote-collections.tsx b/packages/insomnia/src/ui/routes/remote-collections.tsx index 40a409323..8bc6ad49f 100644 --- a/packages/insomnia/src/ui/routes/remote-collections.tsx +++ b/packages/insomnia/src/ui/routes/remote-collections.tsx @@ -254,7 +254,6 @@ interface SyncData { ahead: number; behind: number; }; - remoteBackendProjects: BackendProject[]; } const remoteBranchesCache: Record = {}; @@ -320,16 +319,20 @@ export const syncDataLoader: LoaderFunction = async ({ const vcs = VCSInstance(); const { syncItems } = await getSyncItems({ workspaceId }); const localBranches = (await vcs.getBranchNames()).sort(); - const remoteBranches = ( - remoteBranchesCache[workspaceId] || (await vcs.getRemoteBranchNames()) - ).sort(); const currentBranch = await vcs.getCurrentBranchName(); const history = (await vcs.getHistory()).sort((a, b) => b.created > a.created ? 1 : -1 ); const historyCount = await vcs.getHistoryCount(); const status = await vcs.status(syncItems); - const compare = + + let remoteBranches: string[] = []; + let compare = { ahead: 0, behind: 0 }; + try { + remoteBranches = ( + remoteBranchesCache[workspaceId] || (await vcs.getRemoteBranchNames()) + ).sort(); + compare = remoteCompareCache[workspaceId] || (await vcs.compareRemoteBranch()); const remoteBackendProjects = remoteBackendProjectsCache[workspaceId] || @@ -337,10 +340,10 @@ export const syncDataLoader: LoaderFunction = async ({ teamId: project.parentId, teamProjectId: project.remoteId, })); - remoteBranchesCache[workspaceId] = remoteBranches; remoteCompareCache[workspaceId] = compare; remoteBackendProjectsCache[workspaceId] = remoteBackendProjects; + } catch (e) { } return { syncItems, @@ -351,7 +354,6 @@ export const syncDataLoader: LoaderFunction = async ({ historyCount, status, compare, - remoteBackendProjects, }; } catch (e) { const errorMessage =