chore: cleanup unnecessary multi graph calls in db

namespaces. Add fn and related namespaces to linter
This commit is contained in:
Gabriel Horner
2025-05-09 15:05:14 -04:00
parent 33321e6b9a
commit 2c67b6de11
6 changed files with 15 additions and 13 deletions

View File

@@ -3,7 +3,6 @@
(:require [datascript.core :as d]
[logseq.db.common.entity-plus :as entity-plus]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.property.type :as db-property-type]
[logseq.db.sqlite.util :as sqlite-util]))
(defn- get-file-pid-by-ident
@@ -27,18 +26,12 @@
db-ident
(get-file-pid-by-ident db-ident)))
(defn built-in-has-ref-value?
"Given a built-in's db-ident, determine if its property value is a ref"
[db-ident]
(contains? db-property-type/value-ref-property-types
(get-in db-property/built-in-properties [db-ident :schema :type])))
(defn lookup
"Get the property value by a built-in property's db-ident from coll. For file and db graphs"
[repo block db-ident]
(if (sqlite-util/db-based-graph? repo)
(let [val (get block db-ident)]
(if (built-in-has-ref-value? db-ident) (db-property/property-value-content val) val))
(if (db-property/built-in-has-ref-value? db-ident) (db-property/property-value-content val) val))
(get (:block/properties block) (get-pid repo db-ident))))
(defn get-block-property-value

View File

@@ -6,6 +6,7 @@
[flatland.ordered.map :refer [ordered-map]]
[logseq.common.defkeywords :refer [defkeywords]]
[logseq.common.uuid :as common-uuid]
[logseq.db.frontend.property.type :as db-property-type]
[logseq.db.frontend.db-ident :as db-ident]))
;; Main property vars
@@ -770,3 +771,9 @@
(defn get-property-schema
[property-m]
(select-keys property-m schema-properties))
(defn built-in-has-ref-value?
"Given a built-in's db-ident, determine if its property value is a ref"
[db-ident]
(contains? db-property-type/value-ref-property-types
(get-in built-in-properties [db-ident :schema :type])))

View File

@@ -100,6 +100,9 @@
(defn- validate-multi-graph-fns-not-in-file-or-db
[]
(let [multi-graph-fns ["/db-based-graph\\?" "\\(db-based-graph\\?"
;; from frontend.handler.property.util
"/get-pid"
"logseq.db.common.property-util"
;; Use file-entity-util and entity-util when in a single graph context
"ldb/whiteboard\\?" "ldb/journal\\?" "ldb/page\\?"]
res (grep-many multi-graph-fns (into file-graph-paths db-graph-paths))]

View File

@@ -16,7 +16,6 @@
[frontend.handler.db-based.property :as db-property-handler]
[frontend.handler.notification :as notification]
[frontend.handler.property :as property-handler]
[frontend.handler.property.util :as pu]
[frontend.handler.route :as route-handler]
[frontend.mixins :as mixins]
[frontend.modules.shortcut.core :as shortcut]
@@ -308,7 +307,7 @@
(db-property-handler/set-block-property! (:db/id property)
:logseq.property/icon icon)
(db-property-handler/remove-block-property! (:db/id property)
(pu/get-pid :logseq.property/icon)))
:logseq.property/icon))
(shui/popup-hide! id))
:icon-value icon
:del-btn? (boolean icon)}))]

View File

@@ -117,7 +117,7 @@
(clear-overlay!)
(let [^js container (or (some-> js/document.activeElement (.closest ".page"))
(gdom/getElement "main-content-container"))
icon (get block (pu/get-pid :logseq.property/icon))]
icon (get block :logseq.property/icon)]
(util/schedule
(fn []
(when-let [^js target (some-> (.querySelector container (str "#ls-block-" (str (:block/uuid block))))

View File

@@ -8,10 +8,10 @@
[logseq.db :as ldb]
[logseq.db.common.entity-plus :as entity-plus]
[logseq.db.common.order :as db-order]
[logseq.db.common.property-util :as db-property-util]
[logseq.db.frontend.class :as db-class]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.db.frontend.malli-schema :as db-malli-schema]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.property.build :as db-property-build]
[logseq.db.sqlite.util :as sqlite-util]
[logseq.graph-parser.block :as gp-block]
@@ -49,7 +49,7 @@
(keep (fn [[k v]]
;; TODO: Pass in property type in order to support property
;; types other than :default
(when (db-property-util/built-in-has-ref-value? k)
(when (db-property/built-in-has-ref-value? k)
[k v])))
(into {})))]
(cond-> (if class?