mirror of https://github.com/logseq/logseq
fix: new properties that didn't have :block/journal?
Some page queries depend on the existence of this attribute including graph view ones. This was caught by the validation script. After the fix all pages have this attribute. Creation scripts also updated to use standard timestamp approachpull/10438/head
parent
e9c6fee11a
commit
83e9cda446
|
@ -64,8 +64,7 @@
|
|||
(map (fn [{db-id :db/id}]
|
||||
[:block/uuid (some #(when (= db-id (:db/id %)) (:block/uuid %)) blocks)])
|
||||
v))]
|
||||
:else [a v]
|
||||
)))
|
||||
:else [a v])))
|
||||
(transit/write t-writer))))
|
||||
|
||||
(defn block-with-timestamps
|
||||
|
@ -85,6 +84,14 @@
|
|||
[s]
|
||||
(string/lower-case s))
|
||||
|
||||
(defn build-new-property
|
||||
"Build a standard new property so that it is is consistent across contexts"
|
||||
[block]
|
||||
(block-with-timestamps
|
||||
(merge {:block/type "property"
|
||||
:block/journal? false}
|
||||
block)))
|
||||
|
||||
(defn build-db-initial-data
|
||||
[config-content]
|
||||
(let [initial-files [{:block/uuid (d/squuid)
|
||||
|
@ -99,11 +106,10 @@
|
|||
default-properties (map
|
||||
(fn [[k-keyword {:keys [schema original-name]}]]
|
||||
(let [k-name (name k-keyword)]
|
||||
(block-with-timestamps
|
||||
(build-new-property
|
||||
{:block/schema schema
|
||||
:block/original-name (or original-name k-name)
|
||||
:block/name (sanitize-page-name k-name)
|
||||
:block/uuid (d/squuid)
|
||||
:block/type "property"})))
|
||||
:block/uuid (d/squuid)})))
|
||||
db-property/built-in-properties)]
|
||||
(concat initial-files default-properties)))
|
||||
|
|
|
@ -157,21 +157,18 @@
|
|||
property-db-ids (->> property-uuids
|
||||
(map #(vector (name (first %)) (new-db-id)))
|
||||
(into {}))
|
||||
created-at (js/Date.now)
|
||||
new-properties-tx (mapv (fn [[prop-name uuid]]
|
||||
(sqlite-util/build-new-property
|
||||
(merge {:db/id (or (property-db-ids (name prop-name))
|
||||
(throw (ex-info "No :db/id for property" {:property prop-name})))
|
||||
:block/uuid uuid
|
||||
:block/schema (merge {:type :default}
|
||||
(get-in properties [prop-name :block/schema]))
|
||||
:block/original-name (name prop-name)
|
||||
:block/name (sqlite-util/sanitize-page-name (name prop-name))
|
||||
:block/type "property"
|
||||
:block/created-at created-at
|
||||
:block/updated-at created-at}
|
||||
:block/name (sqlite-util/sanitize-page-name (name prop-name))}
|
||||
(when-let [props (not-empty (get-in properties [prop-name :properties]))]
|
||||
{:block/properties (->block-properties-tx props uuid-maps)
|
||||
:block/refs (build-property-refs props property-db-ids)})))
|
||||
:block/refs (build-property-refs props property-db-ids)}))))
|
||||
property-uuids)
|
||||
pages-and-blocks-tx
|
||||
(vec
|
||||
|
@ -180,17 +177,18 @@
|
|||
(let [page-id (or (:db/id page) (new-db-id))]
|
||||
(into
|
||||
;; page tx
|
||||
[(merge (dissoc page :properties)
|
||||
[(sqlite-util/block-with-timestamps
|
||||
(merge
|
||||
{:db/id page-id
|
||||
:block/original-name (or (:block/original-name page) (string/capitalize (:block/name page)))
|
||||
:block/name (or (:block/name page) (sqlite-util/sanitize-page-name (:block/original-name page)))
|
||||
:block/created-at created-at
|
||||
:block/updated-at created-at}
|
||||
:block/journal? false}
|
||||
(dissoc page :properties)
|
||||
(when (seq (:properties page))
|
||||
{:block/properties (->block-properties-tx (:properties page) uuid-maps)
|
||||
:block/refs (build-property-refs (:properties page) property-db-ids)
|
||||
;; app doesn't do this yet but it should to link property to page
|
||||
:block/path-refs (build-property-refs (:properties page) property-db-ids)}))]
|
||||
:block/path-refs (build-property-refs (:properties page) property-db-ids)})))]
|
||||
;; blocks tx
|
||||
(reduce (fn [acc m]
|
||||
(conj acc
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
[[:block/name :string]
|
||||
[:block/original-name :string]
|
||||
[:block/type {:optional true} [:enum #{"property"} #{"class"} #{"object"} #{"whiteboard"}]]
|
||||
[:block/journal? :boolean]
|
||||
;; TODO: Consider moving to just normal and class after figuring out journal attributes
|
||||
[:block/format {:optional true} [:enum :markdown]]
|
||||
;; TODO: Should this be here or in common?
|
||||
|
@ -51,9 +52,8 @@
|
|||
(concat
|
||||
[:map {:closed false}]
|
||||
page-attrs
|
||||
;; These are optional b/c some built-in pages only have :journal?
|
||||
[[:block/journal? {:optional true} :boolean]
|
||||
[:block/journal-day {:optional true} :int]
|
||||
;; journal-day is only set for journal pages
|
||||
[[:block/journal-day {:optional true} :int]
|
||||
[:block/namespace {:optional true} :int]]
|
||||
page-or-block-attrs)))
|
||||
|
||||
|
@ -61,9 +61,7 @@
|
|||
(vec
|
||||
(concat
|
||||
[:map {:closed false}]
|
||||
[[:block/collapsed? {:optional true} :boolean]
|
||||
;; TODO: Fix bug which introduces journal?
|
||||
[:block/journal? {:optional true} :boolean]]
|
||||
[[:block/collapsed? {:optional true} :boolean]]
|
||||
page-attrs
|
||||
page-or-block-attrs)))
|
||||
|
||||
|
@ -71,9 +69,7 @@
|
|||
(vec
|
||||
(concat
|
||||
[:map {:closed false}]
|
||||
;; TODO: Fix bug which introduces journal?
|
||||
[[:block/journal? {:optional true} :boolean]
|
||||
[:block/namespace {:optional true} :int]
|
||||
[[:block/namespace {:optional true} :int]
|
||||
;; TODO: Require :block/schema
|
||||
[:block/schema
|
||||
{:optional true}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
[frontend.components.page :as page]
|
||||
[frontend.db :as db]
|
||||
[frontend.db-mixins :as db-mixins]
|
||||
[frontend.db.model :as model]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.state :as state]
|
||||
[frontend.ui :as ui]
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[frontend.modules.outliner.core :as outliner-core]
|
||||
[frontend.util :as util]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[malli.util :as mu]
|
||||
[malli.error :as me]))
|
||||
|
||||
|
@ -106,12 +107,11 @@
|
|||
:block/type "property"})]
|
||||
{:outliner-op :save-block}))
|
||||
(when (nil? property) ;if property not exists yet
|
||||
(db/transact! repo [(outliner-core/block-with-timestamps
|
||||
(db/transact! repo [(sqlite-util/build-new-property
|
||||
{:block/schema schema
|
||||
:block/original-name k-name
|
||||
:block/name (util/page-name-sanity-lc k-name)
|
||||
:block/uuid property-uuid
|
||||
:block/type "property"})]
|
||||
:block/uuid property-uuid})]
|
||||
{:outliner-op :insert-blocks}))))
|
||||
|
||||
(defn- reset-block-property-multiple-values!
|
||||
|
|
Loading…
Reference in New Issue