Bladeren bron

fix: be compatible with old queries (:page/name, :page/properties, etc)

Tienson Qin 4 jaren geleden
bovenliggende
commit
05432534e0

+ 1 - 1
src/main/frontend/db.cljs

@@ -40,7 +40,7 @@
   get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left
   get-block-children-ids get-block-file get-block-immediate-children get-block-page
   get-block-page-end-pos get-block-parent get-block-parents get-block-referenced-blocks get-block-refs-count
-  get-blocks-by-priority get-blocks-contents get-collapsed-blocks get-custom-css
+  get-blocks-by-priority get-blocks-contents get-custom-css
   get-date-scheduled-or-deadlines get-db-type get-empty-pages get-file
   get-file-blocks get-file-contents get-file-last-modified-at get-file-no-sub get-file-page get-file-page-id file-exists?
   get-file-pages get-files get-files-blocks get-files-full get-files-that-referenced-page get-journals-length

+ 0 - 9
src/main/frontend/db/model.cljs

@@ -1118,15 +1118,6 @@
   [repo]
   (= :local-native-fs (get-db-type repo)))
 
-(defn get-collapsed-blocks
-  []
-  (d/q
-   '[:find ?content
-     :where
-     [?h :block/collapsed? true]
-     [?h :block/content ?content]]
-   (conn/get-conn)))
-
 (defn get-public-pages
   [db]
   (-> (d/q

+ 15 - 4
src/main/frontend/db/query_react.cljs

@@ -80,14 +80,25 @@
   (let [page-ref? #(and (string? %) (text/page-ref? %))]
     (walk/postwalk
      (fn [f]
-       (if (and (list? f)
-                (= (first f) '=)
-                (= 3 (count f))
-                (some page-ref? (rest f)))
+       (cond
+         ;; backward compatible
+         ;; 1. replace :page/ => :block/
+         (and (keyword? f) (= "page" (namespace f)))
+         (keyword "block" (name f))
+
+         (and (keyword? f) (contains? #{:block/ref-pages :block/ref-blocks} f))
+         :block/refs
+
+         (and (list? f)
+              (= (first f) '=)
+              (= 3 (count f))
+              (some page-ref? (rest f)))
          (let [[x y] (rest f)
                [page-ref sym] (if (page-ref? x) [x y] [y x])
                page-ref (string/lower-case page-ref)]
            (list 'contains? sym (text/page-ref-un-brackets! page-ref)))
+
+         :else
          f)) query)))
 
 (defn react-query

+ 0 - 3
src/main/frontend/db_schema.cljs

@@ -73,9 +73,6 @@
    ;; first block that's not a heading or unordered list
    :block/pre-block? {}
 
-   ;; whether block is collapsed
-   :block/collapsed? {}
-
    ;; scheduled day
    :block/scheduled {}
 

+ 2 - 2
src/main/frontend/handler/editor.cljs

@@ -363,7 +363,7 @@
                    child?
                    false
 
-                   (:block/collapsed? current-block)
+                   (:collapsed (:block/properties current-block))
                    true
 
                    :else
@@ -442,7 +442,7 @@
         new-m {:block/uuid (db/new-block-id)
                :block/content snd-block-text}
         next-block (-> (merge block new-m)
-                       (dissoc :db/id :block/collapsed? :block/properties :block/pre-block? :block/meta)
+                       (dissoc :db/id :block/properties :block/pre-block? :block/meta)
                        (wrap-parse-block))
         {:keys [sibling? blocks]} (profile
                                    "outliner insert block"