From 356f1ffbd76c70128f0f1e23a1a4ca5c7a8e2eee Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 12 Dec 2020 03:28:28 -0500 Subject: [PATCH] Fixes infinite loop with triggerChange If child is splatted, it can trigger a change on itself (e.g. parent) --- src/views/nodes/viewNode.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 3195482..6d83a67 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -108,11 +108,14 @@ export abstract class ViewNode { refresh?(reset?: boolean): boolean | void | Promise | Promise; - @gate() + @gate( + (reset: boolean = false, force: boolean = false, avoidSelf?: ViewNode) => + JSON.stringify([reset, force, avoidSelf?.toString()]), + ) @debug() - triggerChange(reset: boolean = false, force: boolean = false): Promise { + triggerChange(reset: boolean = false, force: boolean = false, avoidSelf?: ViewNode): Promise { // 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) { + if (this.splatted && this.parent != null && this.parent !== avoidSelf) { return this.parent.triggerChange(reset, force); } @@ -354,7 +357,7 @@ export abstract class RepositoryFolderNode< @gate() @debug() async refresh(reset: boolean = false) { - await this.child?.triggerChange(reset); + await this.child?.triggerChange(reset, false, this); await this.ensureSubscription(); }