mirror of https://github.com/logseq/logseq
Speedup initialization
parent
37d2a02f43
commit
028a173547
|
@ -999,7 +999,10 @@
|
|||
(try
|
||||
(match item
|
||||
["Paragraph" l]
|
||||
(->elem :p (map-inline config l))
|
||||
;; TODO: speedup
|
||||
(if (re-find #"\"Export_Snippet\" \"embed\"" (str l))
|
||||
(->elem :div (map-inline config l))
|
||||
(->elem :p (map-inline config l)))
|
||||
["Horizontal_Rule"]
|
||||
(when-not (:slide? config)
|
||||
[:hr])
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
(when today?
|
||||
(let [raw-headings (db/get-page-headings repo page)
|
||||
headings (db/with-dummy-heading raw-headings format nil true)]
|
||||
(prn {:today? today?
|
||||
:raw-headings (count raw-headings)
|
||||
:template (state/get-journal-template)})
|
||||
(when (= 1 (count raw-headings))
|
||||
(when-let [template (state/get-journal-template)]
|
||||
(handler/insert-new-heading!
|
||||
|
|
|
@ -1288,11 +1288,13 @@
|
|||
ffirst))
|
||||
|
||||
(defn reset-config!
|
||||
[repo-url content]
|
||||
(let [config (some->> content
|
||||
(reader/read-string))]
|
||||
(state/set-config! repo-url config)
|
||||
config))
|
||||
([repo-url]
|
||||
(reset-config! repo-url (get-file repo-url config/config-file)))
|
||||
([repo-url content]
|
||||
(when content
|
||||
(let [config (reader/read-string content)]
|
||||
(state/set-config! repo-url config)
|
||||
config))))
|
||||
|
||||
(defn start-db-conn!
|
||||
[me repo listen-handler]
|
||||
|
@ -1318,26 +1320,24 @@
|
|||
(p/then (fn [result]
|
||||
result))
|
||||
(p/catch (fn [error]
|
||||
nil)))]
|
||||
(when stored
|
||||
(let [stored-db (string->db stored)
|
||||
attached-db (d/db-with stored-db [(me-tx stored-db me)])]
|
||||
(when (= (:schema stored-db) files-db-schema) ;; check for code update
|
||||
(reset-conn! db-conn attached-db)))))
|
||||
(p/then
|
||||
(fn []
|
||||
(let [db-name (datascript-db repo)
|
||||
db-conn (d/create-conn schema)]
|
||||
(swap! conns assoc db-name db-conn)
|
||||
(p/let [stored (.getItem localforage-instance db-name)]
|
||||
(if stored
|
||||
(let [stored-db (string->db stored)
|
||||
attached-db (d/db-with stored-db [(me-tx stored-db me)])]
|
||||
(when (= (:schema stored-db) schema) ;; check for code update
|
||||
(reset-conn! db-conn attached-db)))
|
||||
(d/transact! db-conn [(me-tx (d/db db-conn) me)]))
|
||||
(listen-handler repo db-conn)
|
||||
(restore-config-handler repo))))))))))
|
||||
nil)))
|
||||
_ (when stored
|
||||
(let [stored-db (string->db stored)
|
||||
attached-db (d/db-with stored-db [(me-tx stored-db me)])]
|
||||
(when (= (:schema stored-db) files-db-schema) ;; check for code update
|
||||
(reset-conn! db-conn attached-db))))
|
||||
db-name (datascript-db repo)
|
||||
db-conn (d/create-conn schema)
|
||||
_ (swap! conns assoc db-name db-conn)
|
||||
stored (.getItem localforage-instance db-name)
|
||||
_ (if stored
|
||||
(let [stored-db (string->db stored)
|
||||
attached-db (d/db-with stored-db [(me-tx stored-db me)])]
|
||||
(when (= (:schema stored-db) schema) ;; check for code update
|
||||
(reset-conn! db-conn attached-db)))
|
||||
(d/transact! db-conn [(me-tx (d/db db-conn) me)]))
|
||||
_ (restore-config-handler repo)]
|
||||
(listen-handler repo db-conn)))))))
|
||||
|
||||
(defn- build-edges
|
||||
[edges]
|
||||
|
|
|
@ -504,9 +504,7 @@
|
|||
|
||||
(defn restore-config!
|
||||
[repo-url]
|
||||
(p/let [content (load-file repo-url config/config-file)]
|
||||
(when content
|
||||
(db/reset-config! repo-url content))))
|
||||
(db/reset-config! repo-url))
|
||||
|
||||
(defn alter-file
|
||||
[repo path content {:keys [reset? re-render-root?]
|
||||
|
|
Loading…
Reference in New Issue