feat(sync): support offline commit- [INS-4226] (#7811)

* feat(sync): support offline commit
This commit is contained in:
Curry Yang 2024-08-09 16:27:42 +08:00 committed by GitHub
parent 9f24405b79
commit 8f790bf962
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View File

@ -90,7 +90,6 @@ export const SyncDropdown: FC<Props> = ({ gitSyncEnabled }) => {
historyCount: 0,
history: [],
syncItems: [],
remoteBackendProjects: [],
compare: { ahead: 0, behind: 0 },
};

View File

@ -254,7 +254,6 @@ interface SyncData {
ahead: number;
behind: number;
};
remoteBackendProjects: BackendProject[];
}
const remoteBranchesCache: Record<string, string[]> = {};
@ -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 =