Log error if shortcut is missing

This commit is contained in:
Tienson Qin
2022-11-30 22:18:59 +08:00
parent c25695d687
commit ed5d872dbf

View File

@@ -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]