Browse Source

fix: skip false binding

Weihua Lu 4 years ago
parent
commit
436f19ede3
1 changed files with 10 additions and 9 deletions
  1. 10 9
      src/main/frontend/modules/shortcut/core.cljs

+ 10 - 9
src/main/frontend/modules/shortcut/core.cljs

@@ -37,15 +37,16 @@
     ;; register shortcuts
     (doseq [[id _] shortcut-map]
       ;; (log/info :shortcut/install-shortcut {:id id :shortcut (dh/shortcut-binding id)})
-      (doseq [k (dh/shortcut-binding id)]
-        (try
-          (log/debug :shortcut/register-shortcut {:id id :binding k})
-          (.registerShortcut handler (util/keyname id) k)
-          (catch js/Object e
-            (log/error :shortcut/register-shortcut {:id id
-                                                    :binding k
-                                                    :error e})
-            (notification/show! (str/join " " [id k (.-message e)]) :error false)))))
+      (when-not (false? (dh/shortcut-binding id))
+        (doseq [k (dh/shortcut-binding id)]
+          (try
+            (log/debug :shortcut/register-shortcut {:id id :binding k})
+            (.registerShortcut handler (util/keyname id) k)
+            (catch js/Object e
+              (log/error :shortcut/register-shortcut {:id id
+                                                      :binding k
+                                                      :error e})
+              (notification/show! (str/join " " [id k (.-message e)]) :error false))))))
 
     (let [f (fn [e]
               (let [dispatch-fn (get shortcut-map (keyword (.-identifier e)))]