Adds rudimentary "paging" to custom view branch history

This commit is contained in:
Eric Amodio
2017-09-11 23:47:51 -04:00
parent e20ec552b7
commit 77ae37c54c
6 changed files with 77 additions and 19 deletions

View File

@@ -3,22 +3,27 @@ import { Iterables } from '../system';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitNode } from './commitNode';
import { GlyphChars } from '../constants';
import { ExplorerNode, ResourceType } from './explorerNode';
import { ExplorerNode, ResourceType, ShowAllCommitsNode } from './explorerNode';
import { GitBranch, GitService, GitUri } from '../gitService';
export class BranchHistoryNode extends ExplorerNode {
readonly resourceType: ResourceType = 'gitlens:branch-history';
maxCount: number | undefined = undefined;
constructor(public readonly branch: GitBranch, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
super(uri);
}
async getChildren(): Promise<ExplorerNode[]> {
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name, 0);
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name, this.maxCount);
if (log === undefined) return [];
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git))];
const children = Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git));
if (!log.truncated) return [...children];
return [...children, new ShowAllCommitsNode(this, this.context)];
}
async getTreeItem(): Promise<TreeItem> {