Browse Source

Removed unnecessary argument

Taichi Masuyama 4 years ago
parent
commit
3da35ea248
2 changed files with 6 additions and 11 deletions
  1. 5 8
      packages/app/src/server/models/page.ts
  2. 1 3
      packages/app/src/server/service/page.ts

+ 5 - 8
packages/app/src/server/models/page.ts

@@ -46,7 +46,7 @@ export type CreateMethod = (path: string, body: string, user, options) => Promis
 export interface PageModel extends Model<PageDocument> {
   [x: string]: any; // for obsolete methods
   createEmptyPagesByPaths(paths: string[], user: any | null, onlyMigratedAsExistingPages?: boolean, andFilter?): Promise<void>
-  getParentAndFillAncestors(path: string, user, pathsToExcludeNotNormalizedPages?: string[]): Promise<PageDocument & { _id: any }>
+  getParentAndFillAncestors(path: string, user): Promise<PageDocument & { _id: any }>
   findByIdsAndViewer(pageIds: ObjectIdLike[], user, userGroups?, includeEmpty?: boolean): Promise<PageDocument[]>
   findByPathAndViewer(path: string | null, user, userGroups?, useFindOne?: boolean, includeEmpty?: boolean): Promise<PageDocument[]>
   findTargetAndAncestorsByPathOrId(pathOrId: string): Promise<TargetAndAncestorsResult>
@@ -550,7 +550,7 @@ schema.statics.replaceTargetWithPage = async function(exPage, pageToReplaceWith?
  * @param path string
  * @returns Promise<PageDocument>
  */
-schema.statics.getParentAndFillAncestors = async function(path: string, user, pathsToExcludeNotNormalizedPages: string[]): Promise<PageDocument> {
+schema.statics.getParentAndFillAncestors = async function(path: string, user): Promise<PageDocument> {
   const parentPath = nodePath.dirname(path);
 
   const builder1 = new PageQueryBuilder(this.find({ path: parentPath }), true);
@@ -573,13 +573,10 @@ schema.statics.getParentAndFillAncestors = async function(path: string, user, pa
 
   // find ancestors
   const builder2 = new PageQueryBuilder(this.find(), true);
+
   // avoid including not normalized pages
-  if (pathsToExcludeNotNormalizedPages != null) {
-    builder2.addConditionToFilterByApplicableAncestors(pathsToExcludeNotNormalizedPages);
-  }
-  else {
-    builder2.addConditionToFilterByApplicableAncestors(ancestorPaths);
-  }
+  builder2.addConditionToFilterByApplicableAncestors(ancestorPaths);
+
   const ancestors = await builder2
     .addConditionToListByPathsArray(ancestorPaths)
     .addConditionToSortPagesByDescPath()

+ 1 - 3
packages/app/src/server/service/page.ts

@@ -2309,9 +2309,7 @@ class PageService {
       updatedPage = await Page.findById(page._id);
     }
     else {
-      // getParentAndFillAncestors
-      const pathsToExcludeNotNormalizedPages = collectAncestorPaths(page.path);
-      const parent = await Page.getParentAndFillAncestors(page.path, user, pathsToExcludeNotNormalizedPages);
+      const parent = await Page.getParentAndFillAncestors(page.path, user);
       updatedPage = await Page.findOneAndUpdate({ _id: page._id }, { parent: parent._id }, { new: true });
     }