浏览代码

chore: use medley/dissoc-in instead of copied version

Can rely on medley as it is nbb compatible
Gabriel Horner 8 月之前
父节点
当前提交
a4aacf022d

+ 0 - 20
deps/common/src/logseq/common/util.cljs

@@ -246,26 +246,6 @@
        (log/error :parse/read-string-failed e)
        {}))))
 
-;; Copied from Medley
-;; https://github.com/weavejester/medley/blob/d1e00337cf6c0843fb6547aadf9ad78d981bfae5/src/medley/core.cljc#L22
-(defn dissoc-in
-  "Dissociate a value in a nested associative structure, identified by a sequence
-  of keys. Any collections left empty by the operation will be dissociated from
-  their containing structures."
-  ([m ks]
-   (if-let [[k & ks] (seq ks)]
-     (if (seq ks)
-       (let [v (dissoc-in (get m k) ks)]
-         (if (empty? v)
-           (dissoc m k)
-           (assoc m k v)))
-       (dissoc m k))
-     m))
-  ([m ks & kss]
-   (if-let [[ks' & kss] (seq kss)]
-     (recur (dissoc-in m ks) ks' kss)
-     (dissoc-in m ks))))
-
 (defn safe-re-find
   {:malli/schema [:=> [:cat :any :string] [:or :nil :string [:vector [:maybe :string]]]]}
   [pattern s]

+ 2 - 1
deps/db/deps.edn

@@ -12,7 +12,8 @@
   logseq/common                {:local/root "../common"}
   logseq/clj-fractional-indexing        {:git/url "https://github.com/logseq/clj-fractional-indexing"
                                          :sha     "7182b7878410f78536dc2b6df35ed32ef9cd6b61"}
-  metosin/malli {:mvn/version "0.16.1"}}
+  metosin/malli {:mvn/version "0.16.1"}
+  medley/medley {:mvn/version "1.4.0"}}
 
  :aliases
  {:clj-kondo

+ 2 - 2
deps/db/nbb.edn

@@ -2,8 +2,8 @@
  :deps
  {logseq/common
   {:local/root "../common"}
-  metosin/malli
-  {:mvn/version "0.16.1"}
+  medley/medley {:mvn/version "1.4.0"}
+  metosin/malli {:mvn/version "0.16.1"}
   logseq/clj-fractional-indexing        {:git/url "https://github.com/logseq/clj-fractional-indexing"
                                          :sha     "7182b7878410f78536dc2b6df35ed32ef9cd6b61"}
   io.github.nextjournal/nbb-test-runner

+ 3 - 3
deps/db/test/logseq/db/sqlite/export_test.cljs

@@ -7,7 +7,7 @@
             [logseq.db.frontend.validate :as db-validate]
             [logseq.db.sqlite.export :as sqlite-export]
             [logseq.db.test.helper :as db-test]
-            [logseq.common.util :as common-util]))
+            [medley.core :as medley]))
 
 (defn- export-block-and-import-to-another-block
   "Exports given block from one graph/conn, imports it to a 2nd block and then
@@ -266,12 +266,12 @@
     (is (= (-> (expand-properties (:properties original-data))
                (dissoc :user.property/node-p1)
                ;; Shallow property doesn't have class
-               (common-util/dissoc-in [:user.property/p2 :build/property-classes]))
+               (medley/dissoc-in [:user.property/p2 :build/property-classes]))
            (:properties imported-page))
         "Page's properties are imported except for shallow class' property")
     (is (= (-> (expand-classes (:classes original-data))
                ;; Shallow class doesn't have properties
-               (common-util/dissoc-in [:user.class/NodeClass :build/class-properties])
+               (medley/dissoc-in [:user.class/NodeClass :build/class-properties])
                (dissoc :user.class/NodeClass2))
            (:classes imported-page))
         "Page's classes are imported except for shallow property's class")

+ 4 - 3
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -17,7 +17,8 @@
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.whiteboard :as gp-whiteboard]))
+            [logseq.graph-parser.whiteboard :as gp-whiteboard]
+            [medley.core :as medley]))
 
 (defn- filepath->page-name
   [filepath]
@@ -319,9 +320,9 @@
         blocks (map
                 (fn [block]
                   (-> block
-                      (common-util/dissoc-in [:block/parent :block/name])
+                      (medley/dissoc-in [:block/parent :block/name])
                       ;; :block/left here for backward compatibility
-                      (common-util/dissoc-in [:block/left :block/name])))
+                      (medley/dissoc-in [:block/left :block/name])))
                 blocks)
         serialized-page (first pages)
         ;; whiteboard edn file should normally have valid :block/title, :block/name, :block/uuid