Browse Source

Fixes infinite loop with triggerChange

If child is splatted, it can trigger a change on itself (e.g. parent)
main
Eric Amodio 4 years ago
parent
commit
356f1ffbd7
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      src/views/nodes/viewNode.ts

+ 7
- 4
src/views/nodes/viewNode.ts View File

@ -108,11 +108,14 @@ export abstract class ViewNode {
refresh?(reset?: boolean): boolean | void | Promise<void> | Promise<boolean>; refresh?(reset?: boolean): boolean | void | Promise<void> | Promise<boolean>;
@gate()
@gate<RepositoryFolderNode['triggerChange']>(
(reset: boolean = false, force: boolean = false, avoidSelf?: ViewNode) =>
JSON.stringify([reset, force, avoidSelf?.toString()]),
)
@debug() @debug()
triggerChange(reset: boolean = false, force: boolean = false): Promise<void> {
triggerChange(reset: boolean = false, force: boolean = false, avoidSelf?: ViewNode): 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 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); return this.parent.triggerChange(reset, force);
} }
@ -354,7 +357,7 @@ export abstract class RepositoryFolderNode<
@gate() @gate()
@debug() @debug()
async refresh(reset: boolean = false) { async refresh(reset: boolean = false) {
await this.child?.triggerChange(reset);
await this.child?.triggerChange(reset, false, this);
await this.ensureSubscription(); await this.ensureSubscription();
} }

Loading…
Cancel
Save