mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
feat(sync): support offline commit- [INS-4226] (#7811)
* feat(sync): support offline commit
This commit is contained in:
parent
9f24405b79
commit
8f790bf962
@ -90,7 +90,6 @@ export const SyncDropdown: FC<Props> = ({ gitSyncEnabled }) => {
|
|||||||
historyCount: 0,
|
historyCount: 0,
|
||||||
history: [],
|
history: [],
|
||||||
syncItems: [],
|
syncItems: [],
|
||||||
remoteBackendProjects: [],
|
|
||||||
compare: { ahead: 0, behind: 0 },
|
compare: { ahead: 0, behind: 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,7 +254,6 @@ interface SyncData {
|
|||||||
ahead: number;
|
ahead: number;
|
||||||
behind: number;
|
behind: number;
|
||||||
};
|
};
|
||||||
remoteBackendProjects: BackendProject[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteBranchesCache: Record<string, string[]> = {};
|
const remoteBranchesCache: Record<string, string[]> = {};
|
||||||
@ -320,16 +319,20 @@ export const syncDataLoader: LoaderFunction = async ({
|
|||||||
const vcs = VCSInstance();
|
const vcs = VCSInstance();
|
||||||
const { syncItems } = await getSyncItems({ workspaceId });
|
const { syncItems } = await getSyncItems({ workspaceId });
|
||||||
const localBranches = (await vcs.getBranchNames()).sort();
|
const localBranches = (await vcs.getBranchNames()).sort();
|
||||||
const remoteBranches = (
|
|
||||||
remoteBranchesCache[workspaceId] || (await vcs.getRemoteBranchNames())
|
|
||||||
).sort();
|
|
||||||
const currentBranch = await vcs.getCurrentBranchName();
|
const currentBranch = await vcs.getCurrentBranchName();
|
||||||
const history = (await vcs.getHistory()).sort((a, b) =>
|
const history = (await vcs.getHistory()).sort((a, b) =>
|
||||||
b.created > a.created ? 1 : -1
|
b.created > a.created ? 1 : -1
|
||||||
);
|
);
|
||||||
const historyCount = await vcs.getHistoryCount();
|
const historyCount = await vcs.getHistoryCount();
|
||||||
const status = await vcs.status(syncItems);
|
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());
|
remoteCompareCache[workspaceId] || (await vcs.compareRemoteBranch());
|
||||||
const remoteBackendProjects =
|
const remoteBackendProjects =
|
||||||
remoteBackendProjectsCache[workspaceId] ||
|
remoteBackendProjectsCache[workspaceId] ||
|
||||||
@ -337,10 +340,10 @@ export const syncDataLoader: LoaderFunction = async ({
|
|||||||
teamId: project.parentId,
|
teamId: project.parentId,
|
||||||
teamProjectId: project.remoteId,
|
teamProjectId: project.remoteId,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
remoteBranchesCache[workspaceId] = remoteBranches;
|
remoteBranchesCache[workspaceId] = remoteBranches;
|
||||||
remoteCompareCache[workspaceId] = compare;
|
remoteCompareCache[workspaceId] = compare;
|
||||||
remoteBackendProjectsCache[workspaceId] = remoteBackendProjects;
|
remoteBackendProjectsCache[workspaceId] = remoteBackendProjects;
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
syncItems,
|
syncItems,
|
||||||
@ -351,7 +354,6 @@ export const syncDataLoader: LoaderFunction = async ({
|
|||||||
historyCount,
|
historyCount,
|
||||||
status,
|
status,
|
||||||
compare,
|
compare,
|
||||||
remoteBackendProjects,
|
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
|
Loading…
Reference in New Issue
Block a user