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] 191 (fn [state e]
(when-not (util/input? (gobj/get e "target")) (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] {:did-mount (fn [state]
(keyboards/bind-shortcuts!) (keyboards/bind-shortcuts!)
state)} state)}

View File

@ -33,6 +33,14 @@
(state/sidebar-remove-block! id) (state/sidebar-remove-block! id)
(state/sidebar-add-block! current-repo id :contents nil))))) (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! (defn toggle-settings-modal!
[] []
(state/toggle-settings!)) (state/toggle-settings!))

View File

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