From 447e7839fe58f610697f55610efc35454c7fea05 Mon Sep 17 00:00:00 2001 From: virvar Date: Wed, 15 Jun 2016 11:39:38 +0300 Subject: [PATCH] Keep the keyboard open after message sending Former-commit-id: b216d7624a3bacdfcb72c391891b89b1bcf67038 --- src/status_im/chat/views/message_input.cljs | 17 ++++++----------- src/status_im/chat/views/plain_message.cljs | 12 +++--------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/status_im/chat/views/message_input.cljs b/src/status_im/chat/views/message_input.cljs index 4c26e15eb8..e40cfa4f8f 100644 --- a/src/status_im/chat/views/message_input.cljs +++ b/src/status_im/chat/views/message_input.cljs @@ -6,8 +6,7 @@ animated-view icon touchable-highlight - text-input - dismiss-keyboard!]] + text-input]] [status-im.components.animation :as anim] [status-im.chat.views.plain-message :as plain-message] [status-im.chat.views.command :as command] @@ -61,8 +60,7 @@ staged-commands [:get-chat-staged-commands] typing-command? [:typing-command?] commands-input-is-switching? [:animations :commands-input-is-switching?]] - (let [dismiss-keyboard (not (or command typing-command?)) - response? (and command to-msg-id) + (let [response? (and command to-msg-id) message-input? (or (not command) commands-input-is-switching?) animation? commands-input-is-switching?] [text-input (merge {:style (cond @@ -72,7 +70,7 @@ :ref (fn [input] (dispatch [:set-message-input input])) :autoFocus false - :blurOnSubmit dismiss-keyboard + :blurOnSubmit false :onChangeText (fn [text] (when-not animation? ((if message-input? @@ -82,8 +80,7 @@ :onSubmitEditing #(when-not animation? (if message-input? (plain-message/try-send staged-commands - input-message - dismiss-keyboard) + input-message) (command/try-send input-command validator)))} (when command {:accessibility-label :command-input}) @@ -100,8 +97,7 @@ staged-commands [:get-chat-staged-commands] typing-command? [:typing-command?] commands-input-is-switching? [:animations :commands-input-is-switching?]] - (let [dismiss-keyboard (not (or command typing-command?)) - response? (and command to-msg-id) + (let [response? (and command to-msg-id) message-input? (or (not command) commands-input-is-switching?)] [view st/input-container [view st/input-view @@ -117,8 +113,7 @@ (if message-input? (when (plain-message/message-valid? staged-commands input-message) [send-button {:on-press #(plain-message/try-send staged-commands - input-message - dismiss-keyboard) + input-message) :accessibility-label :send-message}]) (if (command/valid? input-command validator) [send-button {:on-press command/send-command diff --git a/src/status_im/chat/views/plain_message.cljs b/src/status_im/chat/views/plain_message.cljs index 7c637ebbd0..0284e0e25f 100644 --- a/src/status_im/chat/views/plain_message.cljs +++ b/src/status_im/chat/views/plain_message.cljs @@ -5,8 +5,7 @@ [status-im.components.react :refer [view animated-view icon - touchable-highlight - dismiss-keyboard!]] + touchable-highlight]] [status-im.components.animation :as anim] [status-im.chat.styles.plain-message :as st] [status-im.constants :refer [response-input-hiding-duration]])) @@ -14,19 +13,14 @@ (defn set-input-message [message] (dispatch [:set-chat-input-text message])) -(defn send [dismiss-keyboard] - (when dismiss-keyboard - (dismiss-keyboard!)) - (dispatch [:send-chat-msg])) - (defn message-valid? [staged-commands message] (or (and (pos? (count message)) (not= "!" message)) (pos? (count staged-commands)))) -(defn try-send [staged-commands message dismiss-keyboard] +(defn try-send [staged-commands message] (when (message-valid? staged-commands message) - (send dismiss-keyboard))) + (dispatch [:send-chat-msg]))) (defn prepare-message-input [message-input] (when message-input