Skip to content

Commit a8b989d

Browse files
committed
Optimizes parallelization on loading Commit Graph
1 parent 74734ff commit a8b989d

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/plus/webviews/graph/graphWebview.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import { onIpc } from '../../../webviews/protocol';
8888
import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController';
8989
import type { SubscriptionChangeEvent } from '../../subscription/subscriptionService';
9090
import type {
91+
BranchState,
9192
DimMergeCommitsParams,
9293
DismissBannerParams,
9394
DoubleClickedParams,
@@ -1754,11 +1755,12 @@ export class GraphWebviewProvider implements WebviewProvider<State> {
17541755
);
17551756

17561757
// Check for GitLens+ access and working tree stats
1757-
const [accessResult, workingStatsResult] = await Promise.allSettled([
1758+
const promises = Promise.allSettled([
17581759
this.getGraphAccess(),
17591760
this.getWorkingTreeStats(),
1761+
this.repository.getBranch(),
1762+
this.repository.getLastFetched(),
17601763
]);
1761-
const [access, visibility] = getSettledValue(accessResult) ?? [];
17621764

17631765
let data;
17641766
if (deferRows) {
@@ -1776,16 +1778,23 @@ export class GraphWebviewProvider implements WebviewProvider<State> {
17761778
this.setSelectedRows(data.id);
17771779
}
17781780

1779-
const lastFetched = await this.repository.getLastFetched();
1780-
const branch = await this.repository.getBranch();
1781-
let branchState;
1781+
const [accessResult, workingStatsResult, branchResult, lastFetchedResult] = await promises;
1782+
const [access, visibility] = getSettledValue(accessResult) ?? [];
1783+
1784+
let branchState: BranchState | undefined;
1785+
1786+
const branch = getSettledValue(branchResult);
17821787
if (branch != null) {
1783-
const remote = await branch.getRemote();
1784-
branchState = {
1785-
...branch.state,
1786-
upstream: branch.upstream?.name,
1787-
provider: remote?.provider?.name,
1788-
};
1788+
branchState = { ...branch.state };
1789+
1790+
if (branch.upstream != null) {
1791+
branchState.upstream = branch.upstream.name;
1792+
1793+
const remote = await branch.getRemote();
1794+
if (remote?.provider != null) {
1795+
branchState.provider = remote.provider.name;
1796+
}
1797+
}
17891798
}
17901799

17911800
return {
@@ -1796,7 +1805,7 @@ export class GraphWebviewProvider implements WebviewProvider<State> {
17961805
selectedRepositoryVisibility: visibility,
17971806
branchName: branch?.name,
17981807
branchState: branchState,
1799-
lastFetched: new Date(lastFetched),
1808+
lastFetched: new Date(getSettledValue(lastFetchedResult)!),
18001809
selectedRows: this._selectedRows,
18011810
subscription: access?.subscription.current,
18021811
allowed: (access?.allowed ?? false) !== false,

0 commit comments

Comments
 (0)