Request auto-selection on typing [chat-ui]

This commit is contained in:
alwx 2017-04-06 13:33:30 +03:00 committed by Roman Volosovskyi
parent a15fb7e2a8
commit 35210f043d
1 changed files with 7 additions and 7 deletions

View File

@ -58,14 +58,14 @@
command-args (split-command-args input-text)
command-name (first command-args)]
(when (.startsWith (or command-name "") const/command-char)
(when-let [command (-> (filter (fn [[{:keys [name]} message-id]]
(and (= name (subs command-name 1))
(= message-id (or (:to-message-id input-metadata)
:any))))
possible-actions)
(ffirst))]
(when-let [[command to-message-id] (-> (filter (fn [[{:keys [name]} message-id]]
(= name (subs command-name 1)))
possible-actions)
(first))]
{:command command
:metadata input-metadata
:metadata (if (not= :any to-message-id)
(assoc input-metadata :to-message-id to-message-id)
input-metadata)
:args (remove empty? (rest command-args))}))))
([{:keys [current-chat-id] :as db} chat-id]
(selected-chat-command db chat-id (get-in db [:chats chat-id :input-text]))))