mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 03:16:37 +00:00
fix: more async queries and export to roam
This commit is contained in:
32
src/main/frontend/external/roam_export.cljs
vendored
32
src/main/frontend/external/roam_export.cljs
vendored
@@ -2,9 +2,9 @@
|
||||
(:require [clojure.set :as s]
|
||||
[clojure.string :as str]
|
||||
[clojure.walk :as walk]
|
||||
[datascript.core :as d]
|
||||
[frontend.db :as db]
|
||||
[frontend.state :as state]))
|
||||
[frontend.db.async :as db-async]
|
||||
[frontend.state :as state]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def todo-marker-regex
|
||||
#"^(NOW|LATER|TODO|DOING|WAITING|WAIT|CANCELED|CANCELLED|STARTED|IN-PROGRESS)")
|
||||
@@ -20,18 +20,18 @@
|
||||
(->> (repeatedly 9 nano-id-char)
|
||||
(str/join)))
|
||||
|
||||
;; TODO: async
|
||||
(defn uuid->uid-map []
|
||||
(let [db (db/get-db (state/get-current-repo))]
|
||||
(->>
|
||||
(d/q '[:find (pull ?r [:block/uuid])
|
||||
:in $
|
||||
:where
|
||||
[?b :block/refs ?r]] db)
|
||||
(map (comp :block/uuid first))
|
||||
(distinct)
|
||||
(map (fn [uuid] [uuid (nano-id)]))
|
||||
(into {}))))
|
||||
(defn <uuid->uid-map []
|
||||
(let [repo (state/get-current-repo)]
|
||||
(p/let [result (db-async/<q repo
|
||||
'[:find (pull ?r [:block/uuid])
|
||||
:in $
|
||||
:where
|
||||
[?b :block/refs ?r]])]
|
||||
(->> result
|
||||
(map (comp :block/uuid first))
|
||||
(distinct)
|
||||
(map (fn [uuid] [uuid (nano-id)]))
|
||||
(into {})))))
|
||||
|
||||
(defn update-content [content uuid->uid-map]
|
||||
(when content ; page block doesn't have content
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
(defn traverse
|
||||
[keyseq vec-tree]
|
||||
(let [uuid->uid-map (uuid->uid-map)]
|
||||
(p/let [uuid->uid-map (<uuid->uid-map)]
|
||||
(walk/postwalk
|
||||
(fn [x]
|
||||
(cond
|
||||
|
||||
Reference in New Issue
Block a user