Browse Source

fix: new journals should only have #Journal

Redundant and confusing also be adding #Page, which is a parent of #Journal, to all journals. Also
remove unused option create!
Gabriel Horner 10 months ago
parent
commit
fb2340c1a1

+ 0 - 1
src/main/frontend/handler/page.cljs

@@ -425,7 +425,6 @@
                           (<create! title {:redirect? false
                                            :split-namespace? false
                                            :create-first-block? (not template)
-                                           :journal? true
                                            :today-journal? true})
                           (state/pub-event! [:journal/insert-template today-page])
                           (ui-handler/re-render-root!)

+ 1 - 1
src/main/frontend/worker/handler/page/db_based/page.cljs

@@ -22,7 +22,7 @@
     (let [type-tag (cond class? :logseq.class/Tag
                          whiteboard? :logseq.class/Whiteboard
                          :else :logseq.class/Page)
-          tags' (conj tags type-tag)
+          tags' (if (:block/journal-day page) tags (conj tags type-tag))
           page' (update page :block/tags
                         (fnil into [])
                         (mapv (fn [tag]

+ 14 - 1
src/test/frontend/worker/handler/page/db_based/page_test.cljs

@@ -78,10 +78,23 @@
   (let [conn (db-test/create-conn)
         [_ page-uuid] (worker-db-page/create! conn "fooz" {})]
     (is (= "fooz" (:block/title (d/entity @conn [:block/uuid page-uuid])))
-        "Valid page created")
+        "Page created correctly")
 
     (is (thrown-with-msg?
          js/Error
          #"can't include \"/"
          (worker-db-page/create! conn "foo/bar" {}))
         "Page can't have '/'n title")))
+
+(deftest create-journal
+  (let [conn (db-test/create-conn)
+        [_ page-uuid] (worker-db-page/create! conn "Dec 16th, 2024" {})]
+
+    (is (= "Dec 16th, 2024" (:block/title (d/entity @conn [:block/uuid page-uuid])))
+        "Journal created correctly")
+
+    (is (= [:logseq.class/Journal]
+           (->> (d/entity @conn [:block/uuid page-uuid])
+                :block/tags
+                (map #(:db/ident (d/entity @conn (:db/id %))))))
+        "New journal only has Journal tag")))