修复模块插入时获取最深节点错误的问题

pull/466/head
ChenX 5 years ago
parent 7a0d58f43e
commit 72aabc60d5

@ -27,16 +27,16 @@ import { TemplateRecord } from "./TemplateRecord";
*/ */
export function GetDeepestTemplate(brs: Board[]): TemplateRecord | undefined export function GetDeepestTemplate(brs: Board[]): TemplateRecord | undefined
{ {
let minDepth = Infinity; let maxDepth = -Infinity;
let deepestTemplate: TemplateRecord; let deepestTemplate: TemplateRecord;
for (let br of brs) for (let br of brs)
{ {
if (br.Template && br.Template.Object) if (br.Template && br.Template.Object)
{ {
let template = br.Template.Object as TemplateRecord; let template = br.Template.Object as TemplateRecord;
if (template.NodeDepth < minDepth) if (template.NodeDepth > maxDepth)
{ {
minDepth = template.NodeDepth; maxDepth = template.NodeDepth;
deepestTemplate = template; deepestTemplate = template;
} }
} }

@ -187,7 +187,7 @@ export class UpdateTemplate
Filter: { Filter: {
filterFunction: (obj, ent) => filterFunction: (obj, ent) =>
{ {
return ent.Template !== undefined; return ent && ent.Template !== undefined;
} }
} }
}); });

Loading…
Cancel
Save