瀏覽代碼

Moves subscription trigger into base

main
Eric Amodio 4 年之前
父節點
當前提交
6f90b9151b
共有 14 個文件被更改,包括 38 次插入60 次删除
  1. +0
    -3
      src/views/branchesView.ts
  2. +0
    -3
      src/views/commitsView.ts
  3. +0
    -4
      src/views/contributorsView.ts
  4. +19
    -8
      src/views/nodes/compareResultsNode.ts
  5. +0
    -3
      src/views/nodes/fileHistoryNode.ts
  6. +0
    -2
      src/views/nodes/fileHistoryTrackerNode.ts
  7. +0
    -3
      src/views/nodes/lineHistoryNode.ts
  8. +0
    -2
      src/views/nodes/repositoriesNode.ts
  9. +0
    -2
      src/views/nodes/repositoryNode.ts
  10. +13
    -15
      src/views/nodes/viewNode.ts
  11. +0
    -3
      src/views/remotesView.ts
  12. +0
    -3
      src/views/stashesView.ts
  13. +0
    -3
      src/views/tagsView.ts
  14. +6
    -6
      src/views/viewBase.ts

+ 0
- 3
src/views/branchesView.ts 查看文件

@ -55,8 +55,6 @@ export class BranchesRepositoryNode extends SubscribeableViewNode
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
this.child = new BranchesNode(this.uri, this.view, this, this.repo);
}
@ -66,7 +64,6 @@ export class BranchesRepositoryNode extends SubscribeableViewNode
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const item = new TreeItem(
this.repo.formattedName ?? this.uri.repoPath ?? '',

+ 0
- 3
src/views/commitsView.ts 查看文件

@ -48,8 +48,6 @@ export class CommitsRepositoryNode extends SubscribeableViewNode {
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
const branch = await this.repo.getBranch();
if (branch == null) return [new MessageNode(this.view, this, 'No commits could be found.')];
@ -76,7 +74,6 @@ export class CommitsRepositoryNode extends SubscribeableViewNode {
async getTreeItem(): Promise<TreeItem> {
this.splatted = false;
void this.ensureSubscription();
const branch = await this.repo.getBranch();

+ 0
- 4
src/views/contributorsView.ts 查看文件

@ -37,8 +37,6 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
this.child = new ContributorsNode(this.uri, this.view, this, this.repo);
}
@ -47,8 +45,6 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode
}
getTreeItem(): TreeItem {
void this.ensureSubscription();
const item = new TreeItem(
this.repo.formattedName ?? this.uri.repoPath ?? '',
TreeItemCollapsibleState.Expanded,

+ 19
- 8
src/views/nodes/compareResultsNode.ts 查看文件

@ -1,5 +1,5 @@
'use strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { NamedRef } from '../../constants';
import { Container } from '../../container';
import { GitRevision } from '../../git/git';
@ -8,18 +8,20 @@ import { debug, gate, log, Strings } from '../../system';
import { CompareView } from '../compareView';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { ContextValues, SubscribeableViewNode, ViewNode } from './viewNode';
import { ContextValues, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
import { TreeViewNodeCollapsibleStateChangeEvent } from '../viewBase';
let instanceId = 0;
export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
export class CompareResultsNode extends ViewNode<CompareView> implements Disposable {
static key = ':compare-results';
static getId(repoPath: string, ref1: string, ref2: string, instanceId: number): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref1}|${ref2}):${instanceId}`;
}
private _children: ViewNode[] | undefined;
private _disposable: Disposable;
private _instanceId: number;
constructor(
@ -32,6 +34,19 @@ export class CompareResultsNode extends SubscribeableViewNode {
) {
super(GitUri.fromRepoPath(repoPath), view);
this._instanceId = instanceId++;
this._disposable = this.view.onDidChangeNodeCollapsibleState(this.onCollapsibleStateChanged, this);
}
dispose() {
this._disposable.dispose();
}
private _collapsibleState: TreeItemCollapsibleState | undefined;
private onCollapsibleStateChanged(e: TreeViewNodeCollapsibleStateChangeEvent<ViewNode>) {
if (e.element !== this) return;
this._collapsibleState = e.state;
}
get id(): string {
@ -78,7 +93,7 @@ export class CompareResultsNode extends SubscribeableViewNode {
this._compareWith.label ??
GitRevision.shorten(this._compareWith.ref, { strings: { working: 'Working Tree' } })
}`,
this._state ?? TreeItemCollapsibleState.Collapsed,
this._collapsibleState ?? TreeItemCollapsibleState.Collapsed,
);
item.contextValue = `${ContextValues.CompareResults}+${
this.comparisonNotation === '..' ? 'twodot' : 'threedot'
@ -190,10 +205,6 @@ export class CompareResultsNode extends SubscribeableViewNode {
void this.triggerChange();
}
protected subscribe() {
return undefined;
}
private get comparisonNotation() {
return this._comparisonNotation ?? (Container.config.advanced.useSymmetricDifferenceNotation ? '...' : '..');
}

+ 0
- 3
src/views/nodes/fileHistoryNode.ts 查看文件

@ -40,8 +40,6 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
this.view.titleDescription = `${this.label}${
this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
@ -92,7 +90,6 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const label = this.label;
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);

+ 0
- 2
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -65,8 +65,6 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
const item = new TreeItem('File History', TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.ActiveFileHistory;
void this.ensureSubscription();
return item;
}

+ 0
- 3
src/views/nodes/lineHistoryNode.ts 查看文件

@ -51,8 +51,6 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
this.view.titleDescription = `${this.label}${
this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
@ -213,7 +211,6 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const label = this.label;
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);

+ 0
- 2
src/views/nodes/repositoriesNode.ts 查看文件

@ -49,8 +49,6 @@ export class RepositoriesNode extends SubscribeableViewNode {
const item = new TreeItem('Repositories', TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.Repositories;
void this.ensureSubscription();
return item;
}

+ 0
- 2
src/views/nodes/repositoryNode.ts 查看文件

@ -197,8 +197,6 @@ export class RepositoryNode extends SubscribeableViewNode {
item.id = this.id;
item.tooltip = tooltip;
void this.ensureSubscription();
return item;
}

+ 13
- 15
src/views/nodes/viewNode.ts 查看文件

@ -4,7 +4,7 @@ import { GitFile, GitReference, GitRevisionReference } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { Logger } from '../../logger';
import { debug, Functions, gate, logName } from '../../system';
import { TreeViewNodeStateChangeEvent, View } from '../viewBase';
import { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase';
export enum ContextValues {
ActiveFileHistory = 'gitlens:history:active:file',
@ -169,7 +169,7 @@ export abstract class SubscribeableViewNode extends V
const disposables = [
this.view.onDidChangeVisibility(this.onVisibilityChanged, this),
this.view.onDidChangeNodeState(this.onNodeStateChanged, this),
this.view.onDidChangeNodeCollapsibleState(this.onNodeCollapsibleStateChanged, this),
];
if (viewSupportsAutoRefresh(this.view)) {
@ -179,16 +179,14 @@ export abstract class SubscribeableViewNode extends V
const getTreeItem = this.getTreeItem;
this.getTreeItem = function (this: SubscribeableViewNode<TView>) {
this._loaded = true;
// TODO@eamodio: Rework, so we can do this here
// void this.ensureSubscription();
void this.ensureSubscription();
return getTreeItem.apply(this);
};
const getChildren = this.getChildren;
this.getChildren = function (this: SubscribeableViewNode<TView>) {
this._loaded = true;
// TODO@eamodio: Rework, so we can do this here
// void this.ensureSubscription();
void this.ensureSubscription();
return getChildren.apply(this);
};
@ -242,19 +240,19 @@ export abstract class SubscribeableViewNode extends V
this.onVisibilityChanged({ visible: this.view.visible });
}
protected onParentStateChanged?(state: TreeItemCollapsibleState): void;
protected onStateChanged?(state: TreeItemCollapsibleState): void;
protected onParentCollapsibleStateChanged?(state: TreeItemCollapsibleState): void;
protected onCollapsibleStateChanged?(state: TreeItemCollapsibleState): void;
protected _state: TreeItemCollapsibleState | undefined;
protected onNodeStateChanged(e: TreeViewNodeStateChangeEvent<ViewNode>) {
protected collapsibleState: TreeItemCollapsibleState | undefined;
protected onNodeCollapsibleStateChanged(e: TreeViewNodeCollapsibleStateChangeEvent<ViewNode>) {
if (e.element === this) {
this._state = e.state;
if (this.onStateChanged !== undefined) {
this.onStateChanged(e.state);
this.collapsibleState = e.state;
if (this.onCollapsibleStateChanged !== undefined) {
this.onCollapsibleStateChanged(e.state);
}
} else if (e.element === this.parent) {
if (this.onParentStateChanged !== undefined) {
this.onParentStateChanged(e.state);
if (this.onParentCollapsibleStateChanged !== undefined) {
this.onParentCollapsibleStateChanged(e.state);
}
}
}

+ 0
- 3
src/views/remotesView.ts 查看文件

@ -52,8 +52,6 @@ export class RemotesRepositoryNode extends SubscribeableViewNode {
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
this.child = new RemotesNode(this.uri, this.view, this, this.repo);
}
@ -63,7 +61,6 @@ export class RemotesRepositoryNode extends SubscribeableViewNode {
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const item = new TreeItem(
this.repo.formattedName ?? this.uri.repoPath ?? '',

+ 0
- 3
src/views/stashesView.ts 查看文件

@ -40,8 +40,6 @@ export class StashesRepositoryNode extends SubscribeableViewNode {
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
this.child = new StashesNode(this.uri, this.view, this, this.repo);
}
@ -51,7 +49,6 @@ export class StashesRepositoryNode extends SubscribeableViewNode {
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const item = new TreeItem(
this.repo.formattedName ?? this.uri.repoPath ?? '',

+ 0
- 3
src/views/tagsView.ts 查看文件

@ -40,8 +40,6 @@ export class TagsRepositoryNode extends SubscribeableViewNode {
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
if (this.child == null) {
this.child = new TagsNode(this.uri, this.view, this, this.repo);
}
@ -51,7 +49,6 @@ export class TagsRepositoryNode extends SubscribeableViewNode {
getTreeItem(): TreeItem {
this.splatted = false;
void this.ensureSubscription();
const item = new TreeItem(
this.repo.formattedName ?? this.uri.repoPath ?? '',

+ 6
- 6
src/views/viewBase.ts 查看文件

@ -74,7 +74,7 @@ export type ViewsWithFiles =
| StashesView
| TagsView;
export interface TreeViewNodeStateChangeEvent<T> extends TreeViewExpansionEvent<T> {
export interface TreeViewNodeCollapsibleStateChangeEvent<T> extends TreeViewExpansionEvent<T> {
state: TreeItemCollapsibleState;
}
@ -103,9 +103,9 @@ export abstract class ViewBase<
return this._onDidChangeVisibility.event;
}
private _onDidChangeNodeState = new EventEmitter<TreeViewNodeStateChangeEvent<ViewNode>>();
get onDidChangeNodeState(): Event<TreeViewNodeStateChangeEvent<ViewNode>> {
return this._onDidChangeNodeState.event;
private _onDidChangeNodeCollapsibleState = new EventEmitter<TreeViewNodeCollapsibleStateChangeEvent<ViewNode>>();
get onDidChangeNodeCollapsibleState(): Event<TreeViewNodeCollapsibleStateChangeEvent<ViewNode>> {
return this._onDidChangeNodeCollapsibleState.event;
}
protected disposable: Disposable | undefined;
@ -261,11 +261,11 @@ export abstract class ViewBase<
}
protected onElementCollapsed(e: TreeViewExpansionEvent<ViewNode>) {
this._onDidChangeNodeState.fire({ ...e, state: TreeItemCollapsibleState.Collapsed });
this._onDidChangeNodeCollapsibleState.fire({ ...e, state: TreeItemCollapsibleState.Collapsed });
}
protected onElementExpanded(e: TreeViewExpansionEvent<ViewNode>) {
this._onDidChangeNodeState.fire({ ...e, state: TreeItemCollapsibleState.Expanded });
this._onDidChangeNodeCollapsibleState.fire({ ...e, state: TreeItemCollapsibleState.Expanded });
}
protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) {

Loading…
取消
儲存