Procházet zdrojové kódy

remove empty pages from duplicated page array

yohei0125 před 4 roky
rodič
revize
b88b087eb8
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      packages/app/src/server/routes/page.js

+ 6 - 2
packages/app/src/server/routes/page.js

@@ -613,11 +613,15 @@ module.exports = function(crowi, app) {
     const pages = await builder.query.lean().clone().exec('find');
 
     if (pages.length >= 2) {
-      // Todo: remove empty pages if any. Immediately return if count of remaining pages are less than 2 after removal
 
       // populate to list
       builder.populateDataToList(User.USER_FIELDS_EXCEPT_CONFIDENTIAL);
-      const identicalPathPages = await builder.query.lean().exec('find');
+      const pages = await builder.query.lean().exec('find');
+
+      // remove empty pages if any.
+      const identicalPathPages = pages.filter(p => !p.isEmpty);
+      // do nothing and return if count of remaining pages are less than 2 after removal
+      if (identicalPathPages.length < 2) return;
 
       return res.render('layout-growi/identical-path-page', {
         identicalPathPages,