|
|
@@ -61,26 +61,25 @@
|
|
|
|
|
|
(defn get-query-result
|
|
|
[state config *query-error *query-triggered? current-block-uuid q options]
|
|
|
- (or (when-let [*result (:query-result config)] @*result)
|
|
|
- (let [query-atom (trigger-custom-query! state *query-error *query-triggered?)
|
|
|
- query-result (and query-atom (rum/react query-atom))
|
|
|
+ (let [query-atom (trigger-custom-query! state *query-error *query-triggered?)
|
|
|
+ query-result (and query-atom (rum/react query-atom))
|
|
|
;; exclude the current one, otherwise it'll loop forever
|
|
|
- remove-blocks (if current-block-uuid [current-block-uuid] nil)
|
|
|
- transformed-query-result (when query-result
|
|
|
- (let [result (db/custom-query-result-transform query-result remove-blocks q)]
|
|
|
- (if (and query-result (coll? result) (:block/uuid (first result)))
|
|
|
- (cond-> result
|
|
|
- (get q :remove-block-children? true)
|
|
|
- tree/filter-top-level-blocks)
|
|
|
- result)))
|
|
|
- group-by-page? (get-group-by-page q options)
|
|
|
- result (if (and group-by-page? (:block/uuid (first transformed-query-result)))
|
|
|
- (let [result (db-utils/group-by-page transformed-query-result)]
|
|
|
- (if (map? result)
|
|
|
- (dissoc result nil)
|
|
|
- result))
|
|
|
- transformed-query-result)]
|
|
|
- (when-let [query-result (:query-result config)]
|
|
|
- (reset! query-result result))
|
|
|
- (when query-atom
|
|
|
- (util/safe-with-meta result (meta @query-atom))))))
|
|
|
+ remove-blocks (if current-block-uuid [current-block-uuid] nil)
|
|
|
+ transformed-query-result (when query-result
|
|
|
+ (let [result (db/custom-query-result-transform query-result remove-blocks q)]
|
|
|
+ (if (and query-result (coll? result) (:block/uuid (first result)))
|
|
|
+ (cond-> result
|
|
|
+ (get q :remove-block-children? true)
|
|
|
+ tree/filter-top-level-blocks)
|
|
|
+ result)))
|
|
|
+ group-by-page? (get-group-by-page q options)
|
|
|
+ result (if (and group-by-page? (:block/uuid (first transformed-query-result)))
|
|
|
+ (let [result (db-utils/group-by-page transformed-query-result)]
|
|
|
+ (if (map? result)
|
|
|
+ (dissoc result nil)
|
|
|
+ result))
|
|
|
+ transformed-query-result)]
|
|
|
+ (when-let [query-result (:query-result config)]
|
|
|
+ (reset! query-result result))
|
|
|
+ (when query-atom
|
|
|
+ (util/safe-with-meta result (meta @query-atom)))))
|