mirror of https://github.com/logseq/logseq
fix: set triggerOnce for references
parent
d39947abe0
commit
dbf82ebdc1
|
@ -2559,7 +2559,7 @@
|
|||
(let [repo (state/get-current-repo)
|
||||
ref? (:ref? config)
|
||||
custom-query? (boolean (:custom-query? config))]
|
||||
(if (and ref? (not custom-query?) (not (:ref-query-child? config)))
|
||||
(if (and (or ref? custom-query?) (not (:ref-query-child? config)))
|
||||
(ui/lazy-visible
|
||||
(fn [] (block-container-inner state repo config block)))
|
||||
(block-container-inner state repo config block))))
|
||||
|
@ -2943,7 +2943,8 @@
|
|||
(ui/block-error "Query Error:" {:content (:query q)})
|
||||
(ui/lazy-visible
|
||||
(fn [] (custom-query* config q))
|
||||
{:debug-id q})))
|
||||
{:debug-id q
|
||||
:trigger-once? false})))
|
||||
|
||||
(defn admonition
|
||||
[config type result]
|
||||
|
@ -3363,7 +3364,8 @@
|
|||
(rum/with-key
|
||||
(breadcrumb-with-container block config)
|
||||
(:db/id block)))
|
||||
{:debug-id page})])))))]
|
||||
{:debug-id page
|
||||
:trigger-once? false})])))))]
|
||||
|
||||
(and (:group-by-page? config)
|
||||
(vector? (first blocks)))
|
||||
|
|
|
@ -59,7 +59,8 @@
|
|||
(blocks-cp repo page)
|
||||
(ui/lazy-visible
|
||||
(fn [] (blocks-cp repo page))
|
||||
{:debug-id (str "journal-blocks " page)}))
|
||||
{:trigger-once? false
|
||||
:debug-id (str "journal-blocks " page)}))
|
||||
|
||||
{})
|
||||
|
||||
|
|
|
@ -232,8 +232,7 @@
|
|||
(ui/lazy-visible
|
||||
(fn []
|
||||
(references* page-name))
|
||||
{:trigger-once? true
|
||||
:debug-id (str page-name " references")})))
|
||||
{:debug-id (str page-name " references")})))
|
||||
|
||||
(rum/defcs unlinked-references-aux
|
||||
< rum/reactive db-mixins/query
|
||||
|
|
|
@ -936,24 +936,17 @@
|
|||
([content-fn]
|
||||
(lazy-visible content-fn nil))
|
||||
([content-fn {:keys [trigger-once? _debug-id]
|
||||
:or {trigger-once? false}}]
|
||||
:or {trigger-once? true}}]
|
||||
(if (or (util/mobile?) (mobile-util/native-platform?))
|
||||
(content-fn)
|
||||
(let [[visible? set-visible!] (rum/use-state false)
|
||||
[last-changed-time set-last-changed-time!] (rum/use-state nil)
|
||||
inViewState (useInView #js {:rootMargin "100px"
|
||||
:triggerOnce trigger-once?
|
||||
:onChange (fn [in-view? entry]
|
||||
(let [self-top (.-top (.-boundingClientRect entry))
|
||||
time' (util/time-ms)]
|
||||
(when (and
|
||||
(or (and (not visible?) in-view?)
|
||||
;; hide only the components below the current top for better ux
|
||||
(and visible? (not in-view?) (> self-top 0)))
|
||||
(or (nil? last-changed-time)
|
||||
(and (some? last-changed-time)
|
||||
(> (- time' last-changed-time) 50))))
|
||||
(set-last-changed-time! time')
|
||||
(let [self-top (.-top (.-boundingClientRect entry))]
|
||||
(when (or (and (not visible?) in-view?)
|
||||
;; hide only the components below the current top for better ux
|
||||
(and visible? (not in-view?) (> self-top 0)))
|
||||
(set-visible! in-view?))))})
|
||||
ref (.-ref inViewState)]
|
||||
(lazy-visible-inner visible? content-fn ref)))))
|
||||
|
|
Loading…
Reference in New Issue