fix: toggle help

pull/1467/head
Tienson Qin 2021-03-13 09:54:38 +08:00
parent 759667e041
commit 21b2c5296a
3 changed files with 11 additions and 3 deletions

View File

@ -292,7 +292,7 @@
;; ?
191 (fn [state e]
(when-not (util/input? (gobj/get e "target"))
(state/sidebar-add-block! (state/get-current-repo) "help" :help nil)))})))
(ui-handler/toggle-help!)))})))
{:did-mount (fn [state]
(keyboards/bind-shortcuts!)
state)}

View File

@ -33,6 +33,14 @@
(state/sidebar-remove-block! id)
(state/sidebar-add-block! current-repo id :contents nil)))))
(defn toggle-help!
[]
(when-let [current-repo (state/get-current-repo)]
(let [id "help"]
(if (state/sidebar-block-exists? id)
(state/sidebar-remove-block! id)
(state/sidebar-add-block! current-repo id :help nil)))))
(defn toggle-settings-modal!
[]
(state/toggle-settings!))

View File

@ -652,8 +652,8 @@
(defn sidebar-remove-block!
[idx]
(update-state! :sidebar/blocks (fn [blocks]
(if (= (str idx) "contents")
(remove #(= (second %) "contents") blocks)
(if (string? idx)
(remove #(= (second %) idx) blocks)
(util/drop-nth idx blocks))))
(when (empty? (:sidebar/blocks @state))
(hide-right-sidebar!)))