Przeglądaj źródła

fix: insert timestamps on creating page entity by default

Junyi Du 4 lat temu
rodzic
commit
bee0018a29

+ 6 - 4
src/main/frontend/format/block.cljs

@@ -238,11 +238,13 @@
        [original-page-name page-name day]))))
 
 (defn page-name->map
-  "with-timestamp?: assign timestampes to the map structure. 
+  "Create a page's map structure given a original page name (string).
+   map as input is supported for legacy compatibility.
+   with-timestamp?: assign timestampes to the map structure. 
     Useful when creating new pages from references or namespaces, 
     as there's no chance to introduce timestamps via editing in page"
   ([original-page-name with-id?]
-   (page-name->map original-page-name with-id? false))
+   (page-name->map original-page-name with-id? true))
   ([original-page-name with-id? with-timestamp?]
    (cond
      (and original-page-name (string? original-page-name))
@@ -314,7 +316,7 @@
                               (distinct))
           refs (->> (distinct (concat refs children-pages))
                     (remove nil?))
-          refs (map (fn [ref] (page-name->map ref with-id? true)) refs)]
+          refs (map (fn [ref] (page-name->map ref with-id?)) refs)]
       (assoc block :refs refs))))
 
 (defn with-block-refs
@@ -449,7 +451,7 @@
                                    :else
                                    nil)) (vals properties))
         page-refs (remove string/blank? page-refs)]
-    (map (fn [page] (page-name->map page true true)) page-refs)))
+    (map (fn [page] (page-name->map page true)) page-refs)))
 
 (defn with-page-block-refs
   [block with-id?]

+ 1 - 1
src/main/frontend/handler/editor.cljs

@@ -268,7 +268,7 @@
   (if (and (:block/pre-block? block)
            (seq (:block/properties block)))
     (let [page-properties (:block/properties block)
-          str->page (fn [n] (block/page-name->map n true true))
+          str->page (fn [n] (block/page-name->map n true))
           refs (->> page-properties
                     (filter (fn [[_ v]] (coll? v)))
                     (vals)

+ 1 - 1
src/main/frontend/handler/extract.cljs

@@ -112,7 +112,7 @@
                             (when (text/namespace-page? page)
                               (->> (util/split-namespace-pages page)
                                    (map (fn [page]
-                                          (-> (block/page-name->map page true true)
+                                          (-> (block/page-name->map page true)
                                               (assoc :block/format format)))))))
           pages (->> (concat
                       [page-entity]