mirror of
https://github.com/logseq/logseq.git
synced 2026-04-30 00:46:23 +00:00
enhance: sub-editing? add use-memo, use-callback
This commit is contained in:
@@ -694,13 +694,18 @@ Similar to re-frame subscriptions"
|
||||
|
||||
(defn sub-editing?
|
||||
[container-block]
|
||||
(let [checkf (fn [s] (boolean (get s container-block)))
|
||||
init-value (checkf @(:editor/editing? @state))]
|
||||
(hooks/use-flow-state
|
||||
init-value
|
||||
(m/eduction
|
||||
(map checkf) (drop-while #(= % init-value)) (dedupe)
|
||||
editing-flow))))
|
||||
(let [checkf (hooks/use-callback
|
||||
(fn [s] (boolean (get s container-block)))
|
||||
[container-block])
|
||||
init-value (checkf @(:editor/editing? @state))
|
||||
flow (hooks/use-memo
|
||||
#(m/eduction
|
||||
(map checkf)
|
||||
(dedupe)
|
||||
(drop-while (fn [x] (identical? x init-value)))
|
||||
editing-flow)
|
||||
[init-value])]
|
||||
(hooks/use-flow-state init-value flow)))
|
||||
|
||||
(defn sub-config
|
||||
"Sub equivalent to get-config which should handle all sub user-config access"
|
||||
|
||||
Reference in New Issue
Block a user