From 71867a967486e3a2d6d1c2ecd2848f154e0c1a92 Mon Sep 17 00:00:00 2001 From: pacamara Date: Sat, 26 May 2018 12:52:31 +0100 Subject: [PATCH] Fixes #4309: Do not allow empty command to be sent --- src/status_im/chat/views/input/send_button.cljs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/status_im/chat/views/input/send_button.cljs b/src/status_im/chat/views/input/send_button.cljs index 85a4825d7c..3e2c884e83 100644 --- a/src/status_im/chat/views/input/send_button.cljs +++ b/src/status_im/chat/views/input/send_button.cljs @@ -15,6 +15,10 @@ (animation/timing spin-value {:toValue to-spin-value :duration 300}))))) +(defn sendable? [input-text] + (let [trimmed (string/trim input-text)] + (not (or (string/blank? trimmed) (= trimmed "/"))))) + (defview send-button-view [] (letsubs [command-completion [:command-completion] selected-command [:selected-chat-command] @@ -24,10 +28,11 @@ :command-completion command-completion})] {:component-did-update on-update} (let [{:keys [hide-send-button sequential-params]} (:command selected-command)] - (when (and (not (string/blank? input-text)) - (or (not selected-command) - (some #{:complete :less-than-needed} [command-completion])) - (not hide-send-button)) + (when + (and (sendable? input-text) + (or (not selected-command) + (some #{:complete :less-than-needed} [command-completion])) + (not hide-send-button)) [react/touchable-highlight {:on-press #(if sequential-params (do (when-not (string/blank? seq-arg-input-text)