فهرست منبع

Added TODO comments

Taichi Masuyama 3 سال پیش
والد
کامیت
a1bcce6af3
2فایلهای تغییر یافته به همراه6 افزوده شده و 12 حذف شده
  1. 5 2
      packages/app/src/server/models/page.ts
  2. 1 10
      packages/app/src/server/service/page.ts

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

@@ -1012,8 +1012,11 @@ schema.statics.removeEmptyPages = async function(pageIdsToNotRemove: ObjectIdLik
   });
 };
 
-schema.statics.findEmptyPageByPath = async function(path: string): Promise<PageDocument | null> {
-  return this.findOne({ path, isEmpty: true });
+// TODO: implement this method
+schema.statics.findNotEmptyParentByPathRecursively = async function(path: string) {
+  // Find a page on the tree by path
+  // Find not empty parent
+  return;
 };
 
 schema.statics.findNotEmptyParentRecursively = async function(target: PageDocument): Promise<PageDocument | null> {

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

@@ -2261,8 +2261,6 @@ class PageService {
   async normalizeParentByPath(path: string, user): Promise<void> {
     const Page = mongoose.model('Page') as unknown as PageModel;
 
-    let emptyPage: PageDocument | null = null;
-
     const pages = await Page.findByPathAndViewer(path, user, null, false);
     if (pages == null || !Array.isArray(pages)) {
       throw Error('Something went wrong while converting pages.');
@@ -2274,12 +2272,6 @@ class PageService {
       if (isForbidden) {
         throw new V5ConversionError('It is not allowed to convert this page.', V5ConversionErrCode.FORBIDDEN);
       }
-
-      emptyPage = await Page.findEmptyPageByPath(path);
-
-      if (emptyPage == null) {
-        throw new V5ConversionError(`Could not find the page "${path}" to convert.`, V5ConversionErrCode.PAGE_NOT_FOUND);
-      }
     }
     if (pages.length > 1) {
       throw new V5ConversionError(
@@ -2293,9 +2285,8 @@ class PageService {
 
     const shouldCreateNewPage = pages[0] == null;
     if (shouldCreateNewPage) {
-      const notEmptyParent = await Page.findNotEmptyParentRecursively(emptyPage);
+      const notEmptyParent = await Page.findNotEmptyParentByPathRecursively(path);
 
-      // TODO: implement systematicallyDeletePage method on PageService
       systematicallyCreatedPage = await Page.createSystematically(
         path,
         'This page was created by GROWI.',