Преглед на файлове

Adds splatting support to ViewNode

main
Eric Amodio преди 4 години
родител
ревизия
63c79caac1
променени са 2 файла, в които са добавени 17 реда и са изтрити 7 реда
  1. +14
    -2
      src/views/nodes/viewNode.ts
  2. +3
    -5
      src/views/viewBase.ts

+ 14
- 2
src/views/nodes/viewNode.ts Целия файл

@ -64,6 +64,8 @@ export abstract class ViewNode {
return node instanceof ViewNode;
}
protected splatted = false;
constructor(uri: GitUri, public readonly view: TView, protected readonly parent?: ViewNode) {
this._uri = uri;
}
@ -82,6 +84,11 @@ export abstract class ViewNode {
abstract getChildren(): ViewNode[] | Promise<ViewNode[]>;
getParent(): ViewNode | undefined {
// If this node has been splatted (e.g. not shown itself, but its children are), then return its grandparent
if (this.splatted) {
return this.parent?.getParent() ?? this.parent;
}
return this.parent;
}
@ -95,8 +102,13 @@ export abstract class ViewNode {
@gate()
@debug()
triggerChange(reset: boolean = false): Promise<void> {
return this.view.refreshNode(this, reset);
triggerChange(reset: boolean = false, force: boolean = false): Promise<void> {
// If this node has been splatted (e.g. not shown itself, but its children are), then delegate the change to its parent
if (this.splatted && this.parent != null) {
return this.parent.triggerChange(reset, force);
}
return this.view.refreshNode(this, reset, force);
}
}

+ 3
- 5
src/views/viewBase.ts Целия файл

@ -460,11 +460,9 @@ export abstract class ViewBase<
@debug({
args: { 0: (n: ViewNode) => n.toString() },
})
async refreshNode(node: ViewNode, reset: boolean = false) {
if (node.refresh != null) {
const cancel = await node.refresh(reset);
if (cancel === true) return;
}
async refreshNode(node: ViewNode, reset: boolean = false, force: boolean = false) {
const cancel = await node.refresh?.(reset);
if (!force && cancel === true) return;
this.triggerNodeChange(node);
}

Зареждане…
Отказ
Запис