mirror of https://github.com/logseq/logseq
fix: db and most frontend lints
parent
097a59d9c6
commit
1aa1d46474
|
@ -56,7 +56,7 @@
|
|||
db-property-type/builtin-schema-types)))
|
||||
|
||||
(def block-properties
|
||||
"Validates a slightly modified verson of :block/properties. Properties are
|
||||
"Validates a slightly modified version of :block/properties. Properties are
|
||||
expected to be a vector of tuples instead of a map in order to validate each
|
||||
property with its property value that is valid for its type"
|
||||
[:sequential property-tuple])
|
||||
|
|
|
@ -61,21 +61,10 @@
|
|||
(remove #(= :page_uuid (first %)))
|
||||
(mapv (partial apply vector eid))))
|
||||
|
||||
(defn restore-initial-data
|
||||
"Given initial sqlite data, returns a datascript connection and other data
|
||||
needed for subsequent restoration"
|
||||
[data & [{:keys [conn-from-datoms-fn] :or {conn-from-datoms-fn d/conn-from-datoms}}]]
|
||||
(let [{:keys [all-pages all-blocks journal-blocks init-data]} (bean/->clj data)
|
||||
uuid->db-id-tmap (transient (hash-map))
|
||||
*next-db-id (atom 100001)
|
||||
assign-id-to-uuid-fn (fn [uuid-str]
|
||||
(or
|
||||
(get uuid->db-id-tmap uuid-str)
|
||||
(let [id @*next-db-id]
|
||||
(conj! uuid->db-id-tmap [uuid-str id])
|
||||
(swap! *next-db-id inc)
|
||||
id)))
|
||||
pages-eav-coll (doall (mapcat (fn [page]
|
||||
(defn- restore-initial-data*
|
||||
"Builds up most datom vectors including all that are assigned new db ids"
|
||||
[assign-id-to-uuid-fn all-pages all-blocks init-data]
|
||||
(let [pages-eav-coll (doall (mapcat (fn [page]
|
||||
(let [eid (assign-id-to-uuid-fn (:uuid page))]
|
||||
(datoms-str->eav-vec (:datoms page) eid)))
|
||||
all-pages))
|
||||
|
@ -95,7 +84,27 @@
|
|||
[[eid :block/uuid (:uuid b)]
|
||||
[eid :block/unknown? true]]
|
||||
(datoms-str->eav-vec (:datoms b) eid))))
|
||||
init-data))
|
||||
init-data))]
|
||||
{:pages-eav-coll pages-eav-coll
|
||||
:all-blocks' all-blocks'
|
||||
:init-data' init-data'}))
|
||||
|
||||
(defn restore-initial-data
|
||||
"Given initial sqlite data, returns a datascript connection and other data
|
||||
needed for subsequent restoration"
|
||||
[data & [{:keys [conn-from-datoms-fn] :or {conn-from-datoms-fn d/conn-from-datoms}}]]
|
||||
(let [{:keys [all-pages all-blocks journal-blocks init-data]} (bean/->clj data)
|
||||
uuid->db-id-tmap (transient (hash-map))
|
||||
*next-db-id (atom 100001)
|
||||
assign-id-to-uuid-fn (fn [uuid-str]
|
||||
(or
|
||||
(get uuid->db-id-tmap uuid-str)
|
||||
(let [id @*next-db-id]
|
||||
(conj! uuid->db-id-tmap [uuid-str id])
|
||||
(swap! *next-db-id inc)
|
||||
id)))
|
||||
{:keys [pages-eav-coll all-blocks' init-data']}
|
||||
(restore-initial-data* assign-id-to-uuid-fn all-pages all-blocks init-data)
|
||||
uuid->db-id-map (persistent! uuid->db-id-tmap)
|
||||
journal-blocks' (mapv
|
||||
(fn [b]
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
[promesa.core :as p]
|
||||
[react-draggable]
|
||||
[rum.core :as rum]
|
||||
[frontend.config :as config]
|
||||
[frontend.modules.outliner.core :as outliner-core]))
|
||||
[frontend.config :as config]))
|
||||
|
||||
(rum/defc commands < rum/reactive
|
||||
[id format]
|
||||
|
|
|
@ -369,7 +369,7 @@
|
|||
(assoc :on-chosen on-chosen)))))
|
||||
|
||||
(rum/defc property-block-value < rum/reactive
|
||||
[value block-cp editor-box opts]
|
||||
[value block-cp editor-box]
|
||||
(let [parent (db/entity [:block/uuid value])
|
||||
parent (db/sub-block (:db/id parent))
|
||||
children (model/sort-by-left (:block/_parent parent) parent)]
|
||||
|
@ -524,7 +524,7 @@
|
|||
opts)
|
||||
|
||||
:block
|
||||
(property-block-value value block-cp editor-box opts)
|
||||
(property-block-value value block-cp editor-box)
|
||||
|
||||
(inline-text {} :markdown (str value)))))]))]))))
|
||||
|
||||
|
|
|
@ -70,9 +70,10 @@
|
|||
[:enum :open :closed])
|
||||
(def rtc-state-validator (m/validator rtc-state-schema))
|
||||
|
||||
(defn- guard-ex
|
||||
[x]
|
||||
(when (instance? ExceptionInfo x) x))
|
||||
;; TODO: Remove or uncomment when used
|
||||
;; (defn- guard-ex
|
||||
;; [x]
|
||||
;; (when (instance? ExceptionInfo x) x))
|
||||
|
||||
(def transit-w (transit/writer :json))
|
||||
(def transit-r (transit/reader :json))
|
||||
|
@ -237,7 +238,7 @@
|
|||
|
||||
(defn apply-remote-update-page-ops
|
||||
[repo update-page-ops]
|
||||
(doseq [{:keys [self page-name] :as op-value } update-page-ops]
|
||||
(doseq [{:keys [self page-name] :as op-value} update-page-ops]
|
||||
(let [old-page-name (:block/name (db/entity repo [:block/uuid (uuid self)]))
|
||||
exist-page (db/entity repo [:block/name page-name])]
|
||||
(cond
|
||||
|
@ -274,8 +275,7 @@
|
|||
[repo data-from-ws]
|
||||
(assert (rtc-const/data-from-ws-validator data-from-ws) data-from-ws)
|
||||
(go
|
||||
(let [
|
||||
affected-blocks-map (:affected-blocks data-from-ws)
|
||||
(let [affected-blocks-map (:affected-blocks data-from-ws)
|
||||
remote-t (:t data-from-ws)
|
||||
local-t (<! (p->c (op/<get-ops&local-tx repo)))]
|
||||
(if (<= remote-t local-t)
|
||||
|
@ -531,7 +531,7 @@
|
|||
(let [maybe-exp (<! (user/<wrap-ensure-id&access-token
|
||||
(<! (<client-op-update-handler state))))]
|
||||
(if (= :expired-token (:anom (ex-data maybe-exp)))
|
||||
(prn ::<loop-for-rtc "quiting loop" maybe-exp)
|
||||
(prn ::<loop-for-rtc "quitting loop" maybe-exp)
|
||||
(recur)))
|
||||
|
||||
stop
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
[frontend.persist-db :as persist-db]
|
||||
[frontend.db.rtc.op :as op]
|
||||
[logseq.outliner.pipeline :as outliner-pipeline]
|
||||
[cljs.reader :as edn]
|
||||
[cljs.reader :as reader]
|
||||
[frontend.db.rtc.const :as rtc-const]))
|
||||
|
||||
(def transit-r (transit/reader :json))
|
||||
|
@ -75,7 +75,7 @@
|
|||
block-tags (map :db/id (:block/tags block))
|
||||
block-type (keep (comp block-type-ident->str :db/ident) (:block/type block))
|
||||
block-schema (some->> (:block/schema block)
|
||||
edn/read-string
|
||||
reader/read-string
|
||||
rtc-const/block-schema-decoder)
|
||||
block-properties (some->> (:block/properties block)
|
||||
(transit/read transit-r))]
|
||||
|
|
|
@ -61,8 +61,7 @@
|
|||
[logseq.graph-parser.util.page-ref :as page-ref]
|
||||
[promesa.core :as p]
|
||||
[rum.core :as rum]
|
||||
[frontend.handler.db-based.property :as db-property-handler]
|
||||
[frontend.db.model :as model]))
|
||||
[frontend.handler.db-based.property :as db-property-handler]))
|
||||
|
||||
;; FIXME: should support multiple images concurrently uploading
|
||||
|
||||
|
@ -790,7 +789,7 @@
|
|||
(cond
|
||||
(and prev-block (:block/name prev-block)
|
||||
(not= (:db/id prev-block) (:db/id (:block/parent block)))
|
||||
(model/hidden-page? (:block/page block))) ; embed page
|
||||
(db-model/hidden-page? (:block/page block))) ; embed page
|
||||
nil
|
||||
|
||||
concat-prev-block?
|
||||
|
@ -2547,7 +2546,6 @@
|
|||
(defn- move-cross-boundary-up-down
|
||||
[direction move-opts]
|
||||
(let [input (state/get-input)
|
||||
input-id (when input (.-id input))
|
||||
line-pos (util/get-first-or-last-line-pos input)
|
||||
repo (state/get-current-repo)
|
||||
f (case direction
|
||||
|
|
Loading…
Reference in New Issue