Replace sidebar block instead of redirecting when clicking breadcrumb

This commit is contained in:
Tienson Qin
2022-05-07 08:34:42 +08:00
parent 4fc479495e
commit ccabb0c8d2
3 changed files with 36 additions and 22 deletions

View File

@@ -769,6 +769,13 @@
(when (empty? (:sidebar/blocks @state))
(hide-right-sidebar!)))
(defn sidebar-replace-block!
[old-sidebar-key new-sidebar-key]
(update-state! :sidebar/blocks (fn [blocks]
(map #(if (= % old-sidebar-key)
new-sidebar-key
%) blocks))))
(defn sidebar-block-exists?
[idx]
(some #(= (second %) idx) (:sidebar/blocks @state)))