Fixes #4309: Do not allow empty command to be sent

This commit is contained in:
pacamara 2018-05-26 12:52:31 +01:00 committed by Roman Volosovskyi
parent 750b95afd6
commit 71867a9674
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 9 additions and 4 deletions

View File

@ -15,6 +15,10 @@
(animation/timing spin-value {:toValue to-spin-value (animation/timing spin-value {:toValue to-spin-value
:duration 300}))))) :duration 300})))))
(defn sendable? [input-text]
(let [trimmed (string/trim input-text)]
(not (or (string/blank? trimmed) (= trimmed "/")))))
(defview send-button-view [] (defview send-button-view []
(letsubs [command-completion [:command-completion] (letsubs [command-completion [:command-completion]
selected-command [:selected-chat-command] selected-command [:selected-chat-command]
@ -24,7 +28,8 @@
:command-completion command-completion})] :command-completion command-completion})]
{:component-did-update on-update} {:component-did-update on-update}
(let [{:keys [hide-send-button sequential-params]} (:command selected-command)] (let [{:keys [hide-send-button sequential-params]} (:command selected-command)]
(when (and (not (string/blank? input-text)) (when
(and (sendable? input-text)
(or (not selected-command) (or (not selected-command)
(some #{:complete :less-than-needed} [command-completion])) (some #{:complete :less-than-needed} [command-completion]))
(not hide-send-button)) (not hide-send-button))