fix: remove default commands

pull/10493/head
Tienson Qin 2023-11-07 16:11:08 +08:00
parent 573a9d4b38
commit 006a61f627
1 changed files with 14 additions and 22 deletions

View File

@ -50,11 +50,6 @@
(def filters search-actions) (def filters search-actions)
(def default-commands
[{:text "Open settings" :icon "settings" :icon-theme :gray}
{:text "Open settings" :icon "settings" :icon-theme :gray}
{:text "Open settings" :icon "settings" :icon-theme :gray}])
;; The results are separated into groups, and loaded/fetched/queried separately ;; The results are separated into groups, and loaded/fetched/queried separately
(def default-results (def default-results
{:recents {:status :success :show :less :items nil} {:recents {:status :success :show :less :items nil}
@ -171,19 +166,19 @@
(let [!input (::input state) (let [!input (::input state)
!results (::results state)] !results (::results state)]
(swap! !results assoc-in [group :status] :loading) (swap! !results assoc-in [group :status] :loading)
(if (empty? @!input) (let [commands (->> (cp-handler/top-commands 1000)
(swap! !results update group merge {:status :success :items default-commands}) (map #(assoc % :t (translate t %))))
(let [commands (->> (cp-handler/top-commands 1000) search-results (if (string/blank? @!input)
(map #(assoc % :t (translate t %)))) commands
search-results (search/fuzzy-search commands @!input {:extract-fn :t})] (search/fuzzy-search commands @!input {:extract-fn :t}))]
(->> search-results (->> search-results
(map #(hash-map :icon "command" (map #(hash-map :icon "command"
:icon-theme :gray :icon-theme :gray
:text (translate t %) :text (translate t %)
:shortcut (:shortcut %) :shortcut (:shortcut %)
:source-command %)) :source-command %))
(hash-map :status :success :items) (hash-map :status :success :items)
(swap! !results update group merge)))))) (swap! !results update group merge)))))
;; The pages search action uses an existing handler ;; The pages search action uses an existing handler
(defmethod load-results :pages [group state] (defmethod load-results :pages [group state]
@ -578,10 +573,7 @@
{:class "text-xl bg-transparent border-none w-full outline-none px-4 py-3" {:class "text-xl bg-transparent border-none w-full outline-none px-4 py-3"
:placeholder (input-placeholder false) :placeholder (input-placeholder false)
:ref #(when-not @input-ref (reset! input-ref %)) :ref #(when-not @input-ref (reset! input-ref %))
:on-change (fn [e] :on-change (fn [e] (handle-input-change state e))
(when (= "" (.-value @input-ref))
(reset! (::filter state) nil))
(handle-input-change state e))
:on-key-down (fn [e] :on-key-down (fn [e]
(let [value (.-value @input-ref) (let [value (.-value @input-ref)
last-char (last value)] last-char (last value)]