Browse Source

fix: check file in case of there's no block/file for the passed page-block

Tienson Qin 4 years ago
parent
commit
b4872fd476
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/main/frontend/modules/file/core.cljs

+ 5 - 2
src/main/frontend/modules/file/core.cljs

@@ -120,7 +120,10 @@
 (defn save-tree
   [page-block tree]
   {:pre [(map? page-block)]}
-  (let [ok-handler #(save-tree-aux! page-block tree)]
-    (if-let [file (:block/file page-block)]
+  (let [ok-handler #(save-tree-aux! page-block tree)
+        file (or (:block/file page-block)
+                 (when-let [page (:db/id (:block/page page-block))]
+                   (:block/file (db-utils/entity page))))]
+    (if file
       (ok-handler)
       (create-file-if-not-exists! page-block ok-handler))))