Skip to content

Commit

Permalink
[#7015] Fix amount validation in chat input
Browse files Browse the repository at this point in the history
  • Loading branch information
speedyFixer committed Jul 26, 2019
1 parent 808aa79 commit 7381139
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/status_im/chat/models/input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@
"command is complete, proceed with command processing"
[cofx input-text command custom-params]
(fx/merge cofx
(commands.sending/validate-and-send input-text command custom-params)
(set-chat-input-text nil)
(if-let [results (commands.sending/validate-and-send input-text command custom-params)]
results
(set-chat-input-text nil))
(process-cooldown)))

(defn command-not-complete-fx
Expand Down
9 changes: 5 additions & 4 deletions src/status_im/ui/screens/chat/input/send_button.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

(defview send-button-view [{:keys [input-text]} on-send-press]
(letsubs [{:keys [command-completion]} [:chats/selected-chat-command]
disconnected? [:disconnected?]
disconnected? [:disconnected?] validation-result [:chats/validation-messages]
{:keys [processing]} [:multiaccounts/login]]
(when (and (sendable? input-text disconnected? processing)
(or (not command-completion)
(#{:complete :less-than-needed} command-completion)))
[react/touchable-highlight
{:on-press on-send-press}
[vector-icons/icon :main-icons/arrow-up
{:container-style style/send-message-container
:accessibility-label :send-message-button
:color :white}]])))
(merge {:accessibility-label :send-message-button}
(if validation-result
{:container-style style/send-message-container-error :color :red}
{:container-style style/send-message-container :color :white}))]])))
7 changes: 5 additions & 2 deletions src/status_im/ui/screens/chat/input/validation_messages.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame]
[status-im.ui.components.react :as react]
[status-im.ui.components.tooltip.views :as tooltip]
[status-im.ui.screens.chat.styles.input.validation-message :as style]
[status-im.i18n :as i18n]))

Expand All @@ -25,5 +26,7 @@
{:title (i18n/label :t/error)
:description validation-result}
validation-result)]
[react/view (style/root (+ input-height chat-input-margin))
[messages-list [validation-message message]]]))))
[tooltip/tooltip (:description message)
{:box-shadow "0px 4px 12px rgba(0, 34, 51, 0.08), 0px 2px 4px rgba(0, 34, 51, 0.16)"
:font-size 12
:bottom-value -13}]))))
3 changes: 3 additions & 0 deletions src/status_im/ui/screens/chat/styles/input/send_button.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
:margin 10
:margin-left 8
:margin-bottom 11})

(def send-message-container-error
(merge send-message-container {:background-color colors/red-transparent-10}))

0 comments on commit 7381139

Please sign in to comment.