From f5348df929963ea43e299db7df7ca90f8d5506c0 Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Fri, 14 Jul 2017 14:00:42 +0300 Subject: [PATCH] fixes https://github.com/status-im/status-react/issues/1394 --- src/status_im/chat/handlers/input.cljs | 8 +++++--- src/status_im/chat/models/input.cljs | 14 +++++++------- .../chat/views/message/request_message.cljs | 18 +++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/status_im/chat/handlers/input.cljs b/src/status_im/chat/handlers/input.cljs index aff8050f16..b31dabc59b 100644 --- a/src/status_im/chat/handlers/input.cljs +++ b/src/status_im/chat/handlers/input.cljs @@ -124,9 +124,11 @@ (remove (fn [[k {:keys [hidden?]}]] hidden?)) (into {})) {:keys [dapp?]} (get-in db [:contacts chat-id])] - (if (and dapp? (str/blank? chat-text)) - (dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil]) - (dispatch [::check-dapp-suggestions chat-id chat-text])) + (when dapp? + (if (str/blank? chat-text) + (dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil]) + (when (every? empty? [requests commands]) + (dispatch [::check-dapp-suggestions chat-id chat-text])))) (-> db (assoc-in [:chats chat-id :request-suggestions] requests) (assoc-in [:chats chat-id :command-suggestions] all-commands))))) diff --git a/src/status_im/chat/models/input.cljs b/src/status_im/chat/models/input.cljs index c5211d2216..f0c24903b2 100644 --- a/src/status_im/chat/models/input.cljs +++ b/src/status_im/chat/models/input.cljs @@ -88,13 +88,13 @@ (subs command-name 1))) possible-actions) (first))] - {:command command - :metadata (if (not= :any to-message-id) - (assoc input-metadata :to-message-id to-message-id) - input-metadata) - :args (if (empty? seq-arguments) - (rest command-args) - seq-arguments)})))) + {:command command + :metadata (if (and (nil? (:to-message-id input-metadata)) (not= :any to-message-id)) + (assoc input-metadata :to-message-id to-message-id) + input-metadata) + :args (if (empty? seq-arguments) + (rest command-args) + seq-arguments)})))) ([{:keys [current-chat-id] :as db} chat-id] (selected-chat-command db chat-id (get-in db [:chats chat-id :input-text])))) diff --git a/src/status_im/chat/views/message/request_message.cljs b/src/status_im/chat/views/message/request_message.cljs index 0b25e12827..99f3d87333 100644 --- a/src/status_im/chat/views/message/request_message.cljs +++ b/src/status_im/chat/views/message/request_message.cljs @@ -56,13 +56,10 @@ :component-will-unmount #(reset! loop? false) :reagent-render - (fn [message-id {:keys [execute-immediately?] command-icon :icon :as command} status-initialized?] + (fn [message-id {command-icon :icon :as command} on-press-handler] (when command [touchable-highlight - {:on-press (if execute-immediately? - #(dispatch [:execute-command-immediately command]) - (when (and (not @answered?) status-initialized?) - #(set-chat-command message-id command))) + {:on-press on-press-handler :style (st/command-request-image-touchable) :accessibility-label (id/chat-request-message-button (:name command))} [animated-view {:style (st/command-request-image-view command scale-anim-val)} @@ -83,11 +80,14 @@ command (if (and params command) (merge command {:prefill prefill :prefill-bot-db (or prefill-bot-db prefillBotDb)}) - command)] + command) + on-press-handler (if (:execute-immediately? command) + #(dispatch [:execute-command-immediately command]) + (when (and (not @answered?) @status-initialized?) + #(set-chat-command message-id command)))] [view st/comand-request-view [touchable-highlight - {:on-press (when (and (not @answered?) @status-initialized?) - #(set-chat-command message-id command))} + {:on-press on-press-handler} [view st/command-request-message-view (if (and @markup (not (string? @markup))) @@ -100,4 +100,4 @@ [text {:style st/style-sub-text :font :default} (:request-text command)]]) - [request-button message-id command @status-initialized?]])))) + [request-button message-id command on-press-handler]]))))