Merge branch 'master' into enhance/i18n

This commit is contained in:
megayu
2026-04-16 16:05:13 +08:00
committed by GitHub
4 changed files with 25 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
(:require ["http" :as http]
["path" :as node-path]
["ws" :as ws]
[clojure.string :as string]
[lambdaisland.glogi :as log]
[logseq.db-sync.index :as index]
[logseq.db-sync.logging :as logging]
@@ -93,6 +94,9 @@
(defn start!
[overrides]
(let [cfg (config/normalize-config overrides)
scheme (if (and (:base-url cfg) (string/starts-with? (:base-url cfg) "https"))
"https"
"http")
index-db (storage/open-index-db (:data-dir cfg))
assets-bucket (assets/make-bucket (node-path/join (:data-dir cfg) "assets"))
registry (atom {})
@@ -105,7 +109,7 @@
(graph/delete-graph! registry deps graph-id))))
server (.createServer http
(fn [req res]
(-> (p/let [request (platform-node/request-from-node req {:scheme "http"})
(-> (p/let [request (platform-node/request-from-node req {:scheme scheme})
response (dispatch/handle-node-fetch {:request request
:env env
:registry registry
@@ -123,7 +127,7 @@
(p/let [_ (index/<index-init! index-db)]
(.on server "upgrade"
(fn [req ^js socket head]
(let [request (platform-node/request-from-node req {:scheme "http"})
(let [request (platform-node/request-from-node req {:scheme scheme})
url (platform/request-url request)
path (.-pathname url)
parsed (node-routes/parse-sync-path path)

View File

@@ -36,6 +36,22 @@
(rest parts)))
(string/join " #"))))
(defn- find-page-add-button
[page-id]
(when page-id
(->> (dom/sel ".block-add-button")
(filter #(= (str page-id) (dom/attr % "parentblockid")))
first)))
(defn- click-page-add-button-with-retry!
[page-id]
(letfn [(poll! [remaining-ms]
(if-let [block-add-button (find-page-add-button page-id)]
(.click block-add-button)
(when (pos? remaining-ms)
(js/setTimeout #(poll! (- remaining-ms 100)) 100))))]
(poll! 500)))
(defn <create!
([title]
(<create! title {}))
@@ -82,13 +98,7 @@
(when redirect?
(route-handler/redirect-to-page! page-uuid)
(when-not today-journal?
(js/setTimeout
(fn []
(when-let [block-add-button (->> (dom/sel ".block-add-button")
(filter #(= (str (:db/id page)) (dom/attr % "parentblockid")))
first)]
(.click block-add-button)))
200)))
(click-page-add-button-with-retry! (:db/id page))))
page)))))))))
;; favorite fns

View File

@@ -125,7 +125,7 @@
(defn- ws-open? [ws]
(sync-transport/ws-open? ws))
(defn- upload-large-title! [repo graph-id title aes-key]
(defn upload-large-title! [repo graph-id title aes-key]
(sync-large-title/upload-large-title!
{:repo repo
:graph-id graph-id

View File

@@ -125,7 +125,7 @@
:process-batch-f
(fn [batch]
(p/let [datoms* (sync-large-title/offload-large-titles-in-datoms-batch
repo graph-id batch aes-key sync-large-title/upload-large-title!)
repo graph-id batch aes-key sync-apply/upload-large-title!)
encrypted-datoms (if aes-key
(sync-crypt/<encrypt-datoms aes-key datoms*)
datoms*)