Răsfoiți Sursa

Improved to ensure to prioritize the oldest parent

Taichi Masuyama 4 ani în urmă
părinte
comite
6d99624490
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      packages/app/src/server/models/page.ts

+ 1 - 1
packages/app/src/server/models/page.ts

@@ -200,7 +200,7 @@ schema.statics.getParentIdAndFillAncestors = async function(path: string, parent
     .exec();
     .exec();
 
 
   const ancestorsMap = new Map(); // Map<path, _id>
   const ancestorsMap = new Map(); // Map<path, _id>
-  ancestors.forEach(page => ancestorsMap.set(page.path, page._id));
+  ancestors.forEach(page => !ancestorsMap.has(page.path) && ancestorsMap.set(page.path, page._id)); // the earlier element should be the true ancestor
 
 
   // bulkWrite to update ancestors
   // bulkWrite to update ancestors
   const nonRootAncestors = ancestors.filter(page => !isTopPage(page.path));
   const nonRootAncestors = ancestors.filter(page => !isTopPage(page.path));