Parcourir la source

Adds splatting support to ViewNode

main
Eric Amodio il y a 4 ans
Parent
révision
63c79caac1
2 fichiers modifiés avec 17 ajouts et 7 suppressions
  1. +14
    -2
      src/views/nodes/viewNode.ts
  2. +3
    -5
      src/views/viewBase.ts

+ 14
- 2
src/views/nodes/viewNode.ts Voir le fichier

@ -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 Voir le fichier

@ -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);
}

Chargement…
Annuler
Enregistrer