Просмотр исходного кода

Improved to ensure to prioritize the oldest parent

Taichi Masuyama 4 лет назад
Родитель
Сommit
6d99624490
1 измененных файлов с 1 добавлено и 1 удалено
  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();
 
   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
   const nonRootAncestors = ancestors.filter(page => !isTopPage(page.path));