Merge branch 'perf/app-start' into fix/multiple-tabs

This commit is contained in:
Tienson Qin
2025-04-11 09:41:19 +08:00
14 changed files with 103 additions and 75 deletions

View File

@@ -548,12 +548,13 @@
:logseq.property.history/scalar-value {:title "History scalar value"
:schema {:type :any
:hide? true}}
:logseq.property/created-by {:title "Node created by"
:schema {;; user-uuid, why not ref?
;; - avoid losing this attr when the user-block is deleted
;; - related user-block maybe not exists yet in graph
:type :string
:logseq.property/created-by {:title "Node created by(deprecated)"
:schema {:type :string
:hide? true}}
:logseq.property/created-by-ref {:title "Node created by"
:schema {:type :entity
:hide? true}
:queryable? true}
:logseq.property/used-template {:title "Used template"
:schema {:type :node
:public? false

View File

@@ -37,7 +37,7 @@
(map (juxt :major :minor)
[(parse-schema-version x) (parse-schema-version y)])))
(def version (parse-schema-version "64.4"))
(def version (parse-schema-version "64.5"))
(defn major-version
"Return a number.

View File

@@ -374,6 +374,11 @@
`skip-existing-page-check?`: if true, allows pages to have the same name"
[original-page-name db with-timestamp? date-formatter
& {:keys [page-uuid class? created-by] :as options}]
(assert (or (nil? created-by)
(and (map? created-by)
(:block/uuid created-by)
(:logseq.property.user/name created-by)))
created-by)
(when-not (and db (common-util/uuid-string? original-page-name)
(not (ldb/page? (d/entity db [:block/uuid (uuid original-page-name)]))))
(let [db-based? (ldb/db-based-graph? db)
@@ -400,7 +405,8 @@
(or (:block/tags page)
[:logseq.class/Page]))]
(cond-> (assoc page :block/tags tags)
created-by (assoc :logseq.property/created-by created-by)))
created-by
(assoc :logseq.property/created-by-ref created-by)))
(assoc page :block/type (or (:block/type page) "page")))))))
(defn- db-namespace-page?

View File

@@ -54,9 +54,13 @@
(defn- update-property-created-by
[block created-by]
(assert (and (map? created-by)
(:block/uuid created-by)
(:logseq.property.user/name created-by))
created-by)
(cond-> block
(and created-by (nil? (:logseq.property/created-by block)))
(assoc :logseq.property/created-by created-by)))
(and created-by (nil? (:logseq.property/created-by-ref block)))
(assoc :logseq.property/created-by-ref created-by)))
(defn- filter-top-level-blocks
[db blocks]
@@ -657,7 +661,7 @@
`replace-empty-target?`: If the `target-block` is an empty block, whether
to replace it, it defaults to be `false`.
`update-timestamps?`: whether to update `blocks` timestamps.
`created-by`: user-uuid, update `:logseq.property/created-by` if exists
`created-by`: user-block, update `:logseq.property/created-by-ref` if exists
``"
[repo conn blocks target-block {:keys [keep-uuid? keep-block-order?
outliner-op replace-empty-target? update-timestamps?
@@ -701,9 +705,9 @@
true
(mapv block-with-timestamps)
db-based?
(mapv #(-> %
(dissoc :block/properties)
(update-property-created-by created-by)))))
(mapv #(cond-> %
true (dissoc :block/properties)
created-by (update-property-created-by created-by)))))
insert-opts {:sibling? sibling?
:replace-empty-target? replace-empty-target?
:keep-uuid? keep-uuid?

View File

@@ -39,16 +39,9 @@
[& props-and-children]
(let [props (first props-and-children)
children (rest props-and-children)
on-key-up' (:on-key-up props)
children (if (map? props) children (cons props children))
props (assoc (if (map? props) props {})
:on-key-up (fn [^js e]
;; If on-key-up is provided, it should be able to control Enter behavior
(if (fn? on-key-up')
(on-key-up' e)
(when (= "Enter" (.-key e))
(some-> (.-target e) (.click))))))]
(apply button-base props children)))
props' (if (map? props) props {})]
(apply button-base props' children)))
(defn button-icon
[variant icon-name {:keys [icon-props size] :as props} child]

View File

@@ -2100,7 +2100,7 @@
[block]
(string/blank? (:block/title block)))
(rum/defcs block-control < rum/reactive
(rum/defcs ^:large-vars/cleanup-todo block-control < rum/reactive
[state config block {:keys [uuid block-id collapsed? *control-show? edit? selected? top? bottom?]}]
(let [doc-mode? (state/sub :document/mode?)
control-show? (util/react *control-show?)
@@ -2169,30 +2169,40 @@
(assoc :class "selected"))
(when
order-list?
[:label (str order-list-idx ".")])])]]]
(cond
(and (or (mobile-util/native-platform?)
(:ui/show-empty-bullets? (state/get-config))
collapsed?
collapsable?
(< (- (util/time-ms) (:block/created-at block)) 500))
(not doc-mode?))
bullet
[:label (str order-list-idx ".")])])]]
bullet' (cond
(and (or (mobile-util/native-platform?)
(:ui/show-empty-bullets? (state/get-config))
collapsed?
collapsable?
(< (- (util/time-ms) (:block/created-at block)) 500))
(not doc-mode?))
bullet
(or
(and empty-content?
(not edit?)
(not top?)
(not bottom?)
(not (util/react *control-show?))
(not (:logseq.property/created-from-property block)))
(and doc-mode?
(not collapsed?)
(not (util/react *control-show?))))
[:span.bullet-container]
(or
(and empty-content?
(not edit?)
(not top?)
(not bottom?)
(not (util/react *control-show?))
(not (:logseq.property/created-from-property block)))
(and doc-mode?
(not collapsed?)
(not (util/react *control-show?))))
[:span.bullet-container]
:else
bullet)))]))
:else
bullet)]
(if (config/db-based-graph?)
(ui/tippy
{:html (fn []
[:div.flex.flex-col.gap-1.p-2
(when-let [created-by (and (ldb/get-graph-rtc-uuid (db/get-db)) (:logseq.property/created-by-ref block))]
[:div (:block/title created-by)])
[:div "Created: " (date/int->local-time-2 (:block/created-at block))]
[:div "Last edited: " (date/int->local-time-2 (:block/updated-at block))]])}
bullet')
bullet')))]))
(rum/defc dnd-separator
[move-to block-content?]

View File

@@ -234,7 +234,6 @@
(let [dirty? (not= (rum/deref *form-data) form-data)]
(shui/button {:size "sm"
:disabled (not dirty?)
:on-key-up util/stop
:on-click (fn []
(-> (<upsert-closed-value! own-property
(cond-> form-data uuid (assoc :id uuid)))

View File

@@ -43,11 +43,12 @@
[original-path & {:keys [href block]}]
(let [web-link? (string/starts-with? original-path "http")
blob-res? (some-> href (string/starts-with? "blob"))
asset-res? (some-> href (string/starts-with? "assets"))
filename (util/node-path.basename original-path)
ext-name "pdf"
url (if blob-res? href
(assets-handler/normalize-asset-resource-url original-path))
filename' (if (or web-link? blob-res?) filename
filename' (if (or asset-res? web-link? blob-res?) filename
(some-> (get-in-repo-assets-full-filename url)
(js/decodeURIComponent) (string/replace '"/" "_")))
filekey (util/safe-sanitize-file-name

View File

@@ -688,15 +688,15 @@
(when-let [grouped-hls (and (sequential? highlights) (group-by :page highlights))]
(doseq [page loaded-pages]
(when-let [^js/HTMLDivElement hls-layer (pdf-utils/resolve-hls-layer! viewer page)]
(let [page-hls (get grouped-hls page)]
(rum/mount
(pdf-highlights-region-container
viewer page-hls {:show-ctx-menu! show-ctx-menu!
:upd-hl! upd-hl!})
hls-layer)))))
(let [page-hls (get grouped-hls page)
hls-render (pdf-highlights-region-container
viewer page-hls {:show-ctx-menu! show-ctx-menu!
:upd-hl! upd-hl!})
^js mounted-root (.-mountedRoot hls-layer)]
(if (nil? mounted-root)
(->> (rum/mount hls-render hls-layer)
(set! (. hls-layer -mountedRoot)))
(.render mounted-root hls-render))))))
;; destroy
#())
[loaded-pages highlights])

View File

@@ -60,13 +60,12 @@
(if (and has-tags? (nil? title'))
(notification/show! "Page name can't include \"#\"." :warning)
(when-not (string/blank? title')
(p/let [current-user-id (user/user-uuid)
options' (if db-based?
(p/let [options' (if db-based?
(cond-> (update options :tags concat (:block/tags parsed-result))
(nil? (:split-namespace? options))
(assoc :split-namespace? true)
current-user-id
(assoc :created-by current-user-id))
true
(assoc :created-by (user/user-block)))
options)
[_page-name page-uuid] (ui-outliner-tx/transact!
{:outliner-op :create-page}

View File

@@ -335,8 +335,7 @@
true
:else
(not has-children?))
current-user-id (user/user-uuid)]
(not has-children?))]
(ui-outliner-tx/transact!
{:outliner-op :insert-blocks}
(save-current-block! {:current-block current-block})
@@ -344,7 +343,7 @@
:keep-uuid? keep-uuid?
:ordered-list? ordered-list?
:replace-empty-target? replace-empty-target?
:created-by current-user-id}))))
:created-by (user/user-block)}))))
(defn- block-self-alone-when-insert?
[config uuid]
@@ -1433,16 +1432,18 @@
(string/replace #"^[.\/\\]*assets[\/\\]+" ""))
dir (or (:dir matched-alias) repo-dir)]
(if (util/electron?)
(let [from (not-empty (.-path file))]
(js/console.debug "Debug: Copy Asset #" dir file-rpath from)
(-> (js/window.apis.copyFileToAssets dir file-rpath from)
(p/then
(fn [dest]
[file-rpath
(if (string? dest) (js/File. #js[] dest) file)
(path/path-join dir file-rpath)
matched-alias]))
(p/catch #(js/console.error "Debug: Copy Asset Error#" %))))
(do (js/console.debug "Debug: Copy Asset #" dir file-rpath)
(-> (if-let [from (not-empty (.-path file))]
(js/window.apis.copyFileToAssets dir file-rpath from)
(p/let [content (.arrayBuffer file)]
(fs/write-file! repo repo-dir file-rpath content {:skip-compare? true})))
(p/then
(fn [dest]
[file-rpath
(if (string? dest) (js/File. #js[] dest) file)
(path/path-join dir file-rpath)
matched-alias]))
(p/catch #(js/console.error "Debug: Copy Asset Error#" %))))
(->
(p/do! (js/console.debug "Debug: Writing Asset #" dir file-rpath)

View File

@@ -85,6 +85,19 @@
parse-jwt
:sub))
(defn user-block
"FIXME: move to somewhere else?"
[]
(when-let [user-uuid* (user-uuid)]
(let [user-name (username)
email* (email)]
{:block/uuid (uuid user-uuid*)
:block/name user-name
:block/title user-name
:block/tags :logseq.class/Page
:logseq.property.user/name user-name
:logseq.property.user/email email*})))
(defn logged-in? []
(some? (state/get-auth-refresh-token)))

View File

@@ -768,7 +768,8 @@
:fix migrate-views}]
["64.3" {:properties [:logseq.property/used-template :logseq.property/template-applied-to]
:classes [:logseq.class/Template]}]
["64.4" {:fix add-group-by-property-for-list-views}]])
["64.4" {:properties [:logseq.property/created-by-ref]}]
["64.5" {:fix add-group-by-property-for-list-views}]])
(let [[major minor] (last (sort (map (comp (juxt :major :minor) db-schema/parse-schema-version first)
schema-version->updates)))

View File

@@ -34,7 +34,7 @@
* :tags - tag uuids that are added to :block/tags
* :persist-op? - when true, add an update-page op
* :properties - properties to add to the page
* :created-by - when set, set :logseq.property/created-by, only for db-based-graphs
* :created-by - user-block, when set, set :logseq.property/created-by-ref, only for db-based-graphs
TODO: Add other options"
[repo conn config title & {:as options}]
(if (ldb/db-based-graph? @conn)