فهرست منبع

Log error if shortcut is missing

Tienson Qin 2 سال پیش
والد
کامیت
9d325ce99b
1فایلهای تغییر یافته به همراه9 افزوده شده و 6 حذف شده
  1. 9 6
      src/main/frontend/handler/command_palette.cljs

+ 9 - 6
src/main/frontend/handler/command_palette.cljs

@@ -79,12 +79,15 @@
   To add i18n support, prefix `id` with command and put that item in dict.
   Example: {:zh-CN {:command.document/open-logseq-doc \"打开文档\"}}"
   [{:keys [id] :as command}]
-  (spec/validate :command/command command)
-  (let [cmds (get-commands)]
-    (if (some (fn [existing-cmd] (= (:id existing-cmd) id)) cmds)
-      (log/error :command/register {:msg "Failed to register command. Command with same id already exist"
-                                    :id  id})
-      (state/set-state! :command-palette/commands (conj cmds command)))))
+  (if (:command/shortcut command)
+    (log/error :shortcut/missing (str "Shortcut is missing for " (:id command)))
+    (do
+      (spec/validate :command/command command)
+      (let [cmds (get-commands)]
+        (if (some (fn [existing-cmd] (= (:id existing-cmd) id)) cmds)
+          (log/error :command/register {:msg "Failed to register command. Command with same id already exist"
+                                        :id  id})
+          (state/set-state! :command-palette/commands (conj cmds command)))))))
 
 (defn unregister
   [id]