Explorar o código

Improved readability

Taichi Masuyama %!s(int64=4) %!d(string=hai) anos
pai
achega
fc90ad27a9
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      packages/app/src/server/models/page.ts

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

@@ -546,9 +546,13 @@ schema.statics.removeLeafEmptyPagesById = async function(pageId: ObjectIdLike):
 
     // delete leaf empty pages
     const isNextPageEmpty = nextPage.isEmpty;
-    const isSiblingsExist = !isNextPageEmpty || await self.exists({ parent: nextPage.parent, _id: { $ne: nextPage._id } }); // evaluate (!isNextPageEmpty ||) first to reduce query
 
-    if (!isNextPageEmpty || isSiblingsExist) {
+    if (!isNextPageEmpty) {
+      return pageIds;
+    }
+
+    const isSiblingsExist = await self.exists({ parent: nextPage.parent, _id: { $ne: nextPage._id } });
+    if (isSiblingsExist) {
       return pageIds;
     }