From e8e6e48b775a19feed0980bf644e76a0f550aa0c Mon Sep 17 00:00:00 2001 From: charlie Date: Fri, 6 May 2022 17:36:43 +0800 Subject: [PATCH] fix(ui): page of all shortcuts crashed when parse unsupported binding keyname --- src/main/frontend/modules/shortcut/data_helper.cljs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/frontend/modules/shortcut/data_helper.cljs b/src/main/frontend/modules/shortcut/data_helper.cljs index f40c2f6e6..549dd54be 100644 --- a/src/main/frontend/modules/shortcut/data_helper.cljs +++ b/src/main/frontend/modules/shortcut/data_helper.cljs @@ -150,9 +150,13 @@ false (let [handler-id (get-group k) shortcut-m (shortcut-map handler-id) + parse-shortcut #(try + (KeyboardShortcutHandler/parseStringShortcut %) + (catch js/Error e + (js/console.error "[shortcut/parse-error]" (str % " - " (.-message e))))) bindings (->> (shortcut-binding k) (map mod-key) - (map KeyboardShortcutHandler/parseStringShortcut) + (map parse-shortcut) (map js->clj)) rest-bindings (->> (map key shortcut-m) (remove #{k}) @@ -160,7 +164,7 @@ (filter vector?) (mapcat identity) (map mod-key) - (map KeyboardShortcutHandler/parseStringShortcut) + (map parse-shortcut) (map js->clj))] (some? (some (fn [b] (some #{b} rest-bindings)) bindings)))))