fix: :block/name shouldn't be updated for custom date formatter

fixes https://github.com/logseq/db-test/issues/830
This commit is contained in:
Tienson Qin
2026-04-29 16:44:22 +08:00
parent 62eac11fe3
commit 69c4d36a61
10 changed files with 58 additions and 11 deletions

View File

@@ -754,7 +754,9 @@
(last child)
(let [{:keys [content children]} (last child)
page-name (subs content 2 (- (count content) 2))]
(rum/with-key (page-reference (assoc config :children children) page-name nil) page-name))))
(rum/with-key (page-reference (assoc config :children children)
(or (:block/uuid page-entity) page-name)
nil) page-name))))
(cond
(and label
(string? label)
@@ -3018,7 +3020,7 @@
:disable-preview? true)]
(when (seq parents)
(let [parents-props (doall
(for [{:block/keys [uuid name title] :as block} parents]
(for [{:block/keys [uuid name] :as block} parents]
(if name
[block (page-cp (cond-> {:disable-preview? true}
disabled?
@@ -3027,7 +3029,7 @@
(let [result (block/parse-title-and-body
uuid
(get block :block/format :markdown)
title)
(:block/raw-title block))
ast-body (:block.temp/ast-body result)
ast-title (:block.temp/ast-title result)
config (assoc config :block/uuid uuid)]

View File

@@ -433,7 +433,7 @@
(let [format (util/evalue e)]
(when-not (string/blank? format)
(p/do!
(property-handler/set-block-property! :logseq.class/Journal
(property-handler/set-block-property! (:block/uuid (db/entity :logseq.class/Journal))
:logseq.property.journal/title-format
format)
(notification/show! (t :settings.general/refresh-required-feedback)))

View File

@@ -25,6 +25,9 @@
(defn- ->block-id
[block-or-id]
(cond
(keyword? block-or-id)
(:block/uuid (db-utils/entity block-or-id))
(de/entity? block-or-id)
(:block/uuid block-or-id)

View File

@@ -103,7 +103,7 @@
(let [next-time (get-next-time (t/plus now (t/weeks 10)) week-unit 1)]
(is (= 11 (in-weeks next-time))))
(let [next-time (get-next-time (t/plus now (t/months 10)) month-unit 1)]
(is (= 11 (in-months next-time))))
(is (contains? #{10 11} (in-months next-time))))
(let [next-time (get-next-time (t/plus now (t/years 10)) year-unit 1)]
(is (= 11 (in-years next-time)))))

View File

@@ -2,9 +2,12 @@
(:require [cljs.test :refer [deftest is testing]]
[datascript.core :as d]
[frontend.worker.pipeline :as worker-pipeline]
[logseq.common.util :as common-util]
[logseq.common.util.date-time :as date-time-util]
[logseq.db :as ldb]
[logseq.db.common.order :as db-order]
[logseq.db.test.helper :as db-test]))
[logseq.db.test.helper :as db-test]
[logseq.outliner.page :as outliner-page]))
(deftest test-built-in-page-updates-that-should-be-reverted
(let [conn (db-test/create-conn-with-blocks
@@ -145,6 +148,21 @@
(is (= "page1-renamed"
(:block/title (d/entity (:db-after result) (:db/id page1)))))))))
(deftest create-journal-page-name-uses-default-formatter-test
(let [conn (db-test/create-conn)]
(d/transact! conn [[:db/add :logseq.class/Journal :logseq.property.journal/title-format "yyyy-MM-dd EEEE"]])
(let [[_ page-uuid] (outliner-page/create! conn "Dec 16th, 2024" {})
page (d/entity @conn [:block/uuid page-uuid])
journal-day (:block/journal-day page)
expected-title (date-time-util/int->journal-title journal-day "yyyy-MM-dd EEEE")
expected-name (-> journal-day
(date-time-util/int->journal-title date-time-util/default-journal-title-formatter)
common-util/page-name-sanity-lc)]
(is (= expected-title (:block/title page))
"Journal title follows configured title format")
(is (= expected-name (:block/name page))
"Journal block/name keeps the default formatter for stable identity"))))
(deftest built-in-tag-must-not-convert-page-child-block-to-class-test
(let [conn (db-test/create-conn-with-blocks
{:pages-and-blocks [{:page {:block/title "page1"}}]})