提交 f7c8db1d 编写于 作者: I isidor

asyncDataTree: fix interesction computation and expand should await on correct refresh call

上级 e5b73ab6
...@@ -43,6 +43,10 @@ function isAncestor<TInput, T>(ancestor: IAsyncDataTreeNode<TInput, T>, descenda ...@@ -43,6 +43,10 @@ function isAncestor<TInput, T>(ancestor: IAsyncDataTreeNode<TInput, T>, descenda
} }
} }
function intersects<TInput, T>(node: IAsyncDataTreeNode<TInput, T>, other: IAsyncDataTreeNode<TInput, T>): boolean {
return node === other || isAncestor(node, other) || isAncestor(other, node);
}
interface IDataTreeListTemplateData<T> { interface IDataTreeListTemplateData<T> {
templateData: T; templateData: T;
} }
...@@ -361,13 +365,13 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable ...@@ -361,13 +365,13 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
return false; return false;
} }
this.tree.expand(node === this.root ? null : node, recursive); const result = this.tree.expand(node === this.root ? null : node, recursive);
if (node.state !== AsyncDataTreeNodeState.Loaded) { if (node.state === AsyncDataTreeNodeState.Loading) {
await this.refreshNode(node, false); await this.currentRefreshCalls.get(node)!;
} }
return true; return result;
} }
toggleCollapsed(element: T, recursive: boolean = false): boolean { toggleCollapsed(element: T, recursive: boolean = false): boolean {
...@@ -507,7 +511,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable ...@@ -507,7 +511,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
let result: Promise<void> | undefined; let result: Promise<void> | undefined;
this.currentRefreshCalls.forEach((refreshPromise, refreshNode) => { this.currentRefreshCalls.forEach((refreshPromise, refreshNode) => {
if (isAncestor(refreshNode, node) || isAncestor(node, refreshNode)) { if (intersects(refreshNode, node)) {
result = refreshPromise.then(() => this.queueRefresh(node, recursive)); result = refreshPromise.then(() => this.queueRefresh(node, recursive));
} }
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册