Kaynağa Gözat

fix: don't create a new file if there's only one block with empty

content
Tienson Qin 4 yıl önce
ebeveyn
işleme
39ab567535
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 7 4
      src/main/frontend/modules/outliner/file.cljs

+ 7 - 4
src/main/frontend/modules/outliner/file.cljs

@@ -8,7 +8,8 @@
             [frontend.util :as util :refer-macros [profile]]
             [frontend.handler.notification :as notification]
             [goog.object :as gobj]
-            [frontend.state :as state]))
+            [frontend.state :as state]
+            [clojure.string :as string]))
 
 (def write-chan (async/chan))
 
@@ -19,9 +20,11 @@
   [page-db-id]
   (let [page-block (db/pull page-db-id)
         page-db-id (:db/id page-block)
-        blocks (model/get-blocks-by-page page-db-id)
-        tree (tree/blocks->vec-tree blocks (:block/name page-block))]
-    (file/save-tree page-block tree)))
+        blocks (model/get-blocks-by-page page-db-id)]
+    (when-not (and (= 1 (count blocks))
+                   (string/blank? (:block/content (first blocks))))
+      (let [tree (tree/blocks->vec-tree blocks (:block/name page-block))]
+        (file/save-tree page-block tree)))))
 
 (defn write-files!
   [page-db-ids]