Skip to content

Commit 91ace9a

Browse files
committed
Consolidates view node splatting
1 parent 8c9572f commit 91ace9a

23 files changed

+37
-67
lines changed

src/views/branchesView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class BranchesViewNode extends RepositoriesSubscribeableNode<BranchesView
8181

8282
const splat = repositories.length === 1;
8383
this.children = repositories.map(
84-
r => new BranchesRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, r, splat),
84+
r => new BranchesRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, splat, r),
8585
);
8686
}
8787

src/views/commitsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class CommitsViewNode extends RepositoriesSubscribeableNode<CommitsView,
145145
const splat = repositories.length === 1;
146146
this.children = repositories.map(
147147
r =>
148-
new CommitsRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, r, splat, {
148+
new CommitsRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, splat, r, {
149149
showBranchAndLastFetched: true,
150150
}),
151151
);

src/views/contributorsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class ContributorsViewNode extends RepositoriesSubscribeableNode<Contribu
7979

8080
const splat = repositories.length === 1;
8181
this.children = repositories.map(
82-
r => new ContributorsRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, r, splat),
82+
r => new ContributorsRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, splat, r),
8383
);
8484
}
8585

src/views/nodes/abstract/repositoriesSubscribeableNode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ export abstract class RepositoriesSubscribeableNode<
1313
TView extends View = View,
1414
TChild extends ViewNode = ViewNode,
1515
> extends SubscribeableViewNode<'repositories', TView, TChild> {
16-
protected override splatted = true;
17-
1816
constructor(view: TView) {
19-
super('repositories', unknownGitUri, view);
17+
super('repositories', unknownGitUri, view, undefined, true);
2018
}
2119

2220
override async getSplattedChild(): Promise<TChild | undefined> {

src/views/nodes/abstract/repositoryFolderNode.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,18 @@ export abstract class RepositoryFolderNode<
2020
TView extends View = View,
2121
TChild extends ViewNode = ViewNode,
2222
> extends SubscribeableViewNode<'repo-folder', TView> {
23-
protected override splatted = true;
24-
2523
constructor(
2624
uri: GitUri,
2725
view: TView,
2826
protected override readonly parent: ViewNode,
29-
public readonly repo: Repository,
3027
splatted: boolean,
28+
public readonly repo: Repository,
3129
private readonly options?: { showBranchAndLastFetched?: boolean },
3230
) {
33-
super('repo-folder', uri, view, parent);
31+
super('repo-folder', uri, view, parent, splatted);
3432

3533
this.updateContext({ repository: this.repo });
3634
this._uniqueId = getViewNodeId(this.type, this.context);
37-
38-
this.splatted = splatted;
3935
}
4036

4137
private _child: TChild | undefined;
@@ -67,8 +63,6 @@ export abstract class RepositoryFolderNode<
6763
}
6864

6965
async getTreeItem(): Promise<TreeItem> {
70-
this.splatted = false;
71-
7266
const branch = await this.repo.git.branches.getBranch();
7367
const ahead = Boolean(branch?.upstream?.state.ahead);
7468
const behind = Boolean(branch?.upstream?.state.behind);

src/views/nodes/abstract/subscribeableViewNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export abstract class SubscribeableViewNode<
2121

2222
protected loaded: boolean = false;
2323

24-
constructor(type: Type, uri: GitUri, view: TView, parent?: ViewNode) {
25-
super(type, uri, view, parent);
24+
constructor(type: Type, uri: GitUri, view: TView, parent?: ViewNode, splatted?: boolean) {
25+
super(type, uri, view, parent, splatted);
2626

2727
const disposables = [
2828
weakEvent(this.view.onDidChangeVisibility, this.onVisibilityChanged, this),

src/views/nodes/abstract/viewNode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export abstract class ViewNode<
238238
}
239239

240240
protected _uniqueId!: string;
241-
protected splatted = false;
241+
splatted = false;
242242
// NOTE: @eamodio uncomment to track node leaks
243243
// readonly uuid = uuid();
244244

@@ -247,8 +247,12 @@ export abstract class ViewNode<
247247
// public readonly id: string | undefined,
248248
uri: GitUri,
249249
public readonly view: TView,
250-
protected parent?: ViewNode,
250+
protected parent?: ViewNode | undefined,
251+
//** Indicates if this node is only shown as its children, not itself */
252+
splatted?: boolean,
251253
) {
254+
this.splatted = splatted ?? false;
255+
252256
// NOTE: @eamodio uncomment to track node leaks
253257
// queueMicrotask(() => this.view.registerNode(this));
254258
this._uri = uri;

src/views/nodes/abstract/viewRefNode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export abstract class ViewRefNode<
1717
uri: GitUri,
1818
view: TView,
1919
protected override readonly parent: ViewNode,
20+
splatted?: boolean,
2021
) {
21-
super(type, uri, view, parent);
22+
super(type, uri, view, parent, splatted);
2223
}
2324

2425
abstract get ref(): TReference;

src/views/nodes/branchNode.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class BranchNode
7171
limit: number | undefined;
7272

7373
private readonly options: Options;
74-
protected override splatted = true;
7574

7675
constructor(
7776
uri: GitUri,
@@ -83,7 +82,7 @@ export class BranchNode
8382
public readonly root: boolean,
8483
options?: Partial<Options>,
8584
) {
86-
super('branch', uri, view, parent);
85+
super('branch', uri, view, parent, root);
8786

8887
this.updateContext({ repository: repo, branch: branch, root: root });
8988
this._uniqueId = getViewNodeId(this.type, this.context);
@@ -397,8 +396,6 @@ export class BranchNode
397396
}
398397

399398
async getTreeItem(): Promise<TreeItem> {
400-
this.splatted = false;
401-
402399
const parts = await getBranchNodeParts(this.view.container, this.branch, this.current, {
403400
avatars: this.view.config.avatars,
404401
pendingPullRequest: this.getState('pendingPullRequest'),

src/views/nodes/branchesNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class BranchesNode extends CacheableChildrenViewNode<'branches', ViewsWit
2121
protected override readonly parent: ViewNode,
2222
public readonly repo: Repository,
2323
) {
24-
super('branches', uri, view, parent);
24+
super('branches', uri, view, parent, true);
2525

2626
this.updateContext({ repository: repo });
2727
this._uniqueId = getViewNodeId(this.type, this.context);

0 commit comments

Comments
 (0)