Browse Source

fix: lint

Tienson Qin 4 months ago
parent
commit
5c506e340a

+ 44 - 40
deps/outliner/src/logseq/outliner/validate.cljs

@@ -65,51 +65,55 @@
                                                           (string/join ns-util/parent-char))))
                                :type :warning}}))))
 
+(defn- another-id-q
+  [entity]
+  (cond
+    (ldb/property? entity)
+    ;; Property names are unique in that they can
+    ;; have the same names as built-in property names
+    '[:find [?b ...]
+      :in $ ?eid ?title [?tag-id ...]
+      :where
+      [?b :block/title ?title]
+      [?b :block/tags ?tag-id]
+      [(missing? $ ?b :logseq.property/built-in?)]
+      [(not= ?b ?eid)]]
+    (:logseq.property.class/extends entity)
+    '[:find [?b ...]
+      :in $ ?eid ?title [?tag-id ...]
+      :where
+      [?b :block/title ?title]
+      [?b :block/tags ?tag-id]
+      [(not= ?b ?eid)]
+      ;; same extends
+      [?b :logseq.property.class/extends ?bp]
+      [?eid :logseq.property.class/extends ?ep]
+      [(= ?bp ?ep)]]
+    (:block/parent entity)
+    '[:find [?b ...]
+      :in $ ?eid ?title [?tag-id ...]
+      :where
+      [?b :block/title ?title]
+      [?b :block/tags ?tag-id]
+      [(not= ?b ?eid)]
+      ;; same parent
+      [?b :block/parent ?bp]
+      [?eid :block/parent ?ep]
+      [(= ?bp ?ep)]]
+    :else
+    '[:find [?b ...]
+      :in $ ?eid ?title [?tag-id ...]
+      :where
+      [?b :block/title ?title]
+      [?b :block/tags ?tag-id]
+      [(not= ?b ?eid)]]))
+
 (defn- validate-unique-for-page
   [db new-title {:block/keys [tags] :as entity}]
   (cond
     (seq tags)
     (when-let [another-id (first
-                           (d/q (cond
-                                  (ldb/property? entity)
-                                  ;; Property names are unique in that they can
-                                  ;; have the same names as built-in property names
-                                  '[:find [?b ...]
-                                    :in $ ?eid ?title [?tag-id ...]
-                                    :where
-                                    [?b :block/title ?title]
-                                    [?b :block/tags ?tag-id]
-                                    [(missing? $ ?b :logseq.property/built-in?)]
-                                    [(not= ?b ?eid)]]
-                                  (:logseq.property.class/extends entity)
-                                  '[:find [?b ...]
-                                    :in $ ?eid ?title [?tag-id ...]
-                                    :where
-                                    [?b :block/title ?title]
-                                    [?b :block/tags ?tag-id]
-                                    [(not= ?b ?eid)]
-                                    ;; same extends
-                                    [?b :logseq.property.class/extends ?bp]
-                                    [?eid :logseq.property.class/extends ?ep]
-                                    [(= ?bp ?ep)]]
-                                  (:block/parent entity)
-                                  '[:find [?b ...]
-                                    :in $ ?eid ?title [?tag-id ...]
-                                    :where
-                                    [?b :block/title ?title]
-                                    [?b :block/tags ?tag-id]
-                                    [(not= ?b ?eid)]
-                                    ;; same parent
-                                    [?b :block/parent ?bp]
-                                    [?eid :block/parent ?ep]
-                                    [(= ?bp ?ep)]]
-                                  :else
-                                  '[:find [?b ...]
-                                    :in $ ?eid ?title [?tag-id ...]
-                                    :where
-                                    [?b :block/title ?title]
-                                    [?b :block/tags ?tag-id]
-                                    [(not= ?b ?eid)]])
+                           (d/q (another-id-q entity)
                                 db
                                 (:db/id entity)
                                 new-title

+ 0 - 1
src/main/frontend/components/library.cljs

@@ -3,7 +3,6 @@
   (:require [clojure.string :as string]
             [frontend.components.select :as components-select]
             [frontend.db :as db]
-            [frontend.handler.db-based.property :as db-property-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.search :as search]
             [frontend.state :as state]