Speedup initialization

pull/645/head
Tienson Qin 2020-07-07 14:45:50 +08:00
parent 37d2a02f43
commit 028a173547
4 changed files with 30 additions and 32 deletions

View File

@ -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])

View File

@ -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!

View File

@ -1288,11 +1288,13 @@
ffirst))
(defn reset-config!
[repo-url content]
(let [config (some->> content
(reader/read-string))]
([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))
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
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
(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)]))
(listen-handler repo db-conn)
(restore-config-handler repo))))))))))
_ (restore-config-handler repo)]
(listen-handler repo db-conn)))))))
(defn- build-edges
[edges]

View File

@ -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?]