From 4e488d91b9defc377636af0ea13fd13ee2f644c1 Mon Sep 17 00:00:00 2001 From: alwx Date: Wed, 19 Apr 2017 12:26:10 +0300 Subject: [PATCH] Pre-filling /send response with amount (#996) --- externs/externs.js | 1 - src/status_im/chat/handlers/input.cljs | 11 +++++++---- src/status_im/chat/views/message/request_message.cljs | 5 ++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/externs/externs.js b/externs/externs.js index de0491a06d..909fa417f4 100644 --- a/externs/externs.js +++ b/externs/externs.js @@ -1,5 +1,4 @@ var TopLevel = { -"abs" : function () {}, "ActionSheetIOS" : function () {}, "addEntropy" : function () {}, "addEventListener" : function () {}, diff --git a/src/status_im/chat/handlers/input.cljs b/src/status_im/chat/handlers/input.cljs index f05977762b..08663f7956 100644 --- a/src/status_im/chat/handlers/input.cljs +++ b/src/status_im/chat/handlers/input.cljs @@ -37,19 +37,22 @@ (handlers/register-handler :select-chat-input-command (handlers/side-effect! - (fn [{:keys [current-chat-id chat-ui-props] :as db} [_ {:keys [name prefill] :as command} metadata]] + (fn [{:keys [current-chat-id chat-ui-props] :as db} + [_ {:keys [name prefill sequential-params] :as command} metadata]] (dispatch [:set-chat-input-text (str const/command-char name const/spacing-char - (input-model/join-command-args prefill))]) + (when-not sequential-params + (input-model/join-command-args prefill)))]) (dispatch [:set-chat-input-metadata metadata]) (dispatch [:set-chat-ui-props :show-suggestions? false]) (dispatch [:set-chat-ui-props :result-box nil]) (dispatch [:set-chat-ui-props :validation-messages nil]) (dispatch [:load-chat-parameter-box command 0]) - (if (:sequential-params command) + (if sequential-params (js/setTimeout - #(dispatch [:chat-input-focus :seq-input-ref]) + #(do (dispatch [:chat-input-focus :seq-input-ref]) + (dispatch [:set-chat-seq-arg-input-text (str/join const/spacing-char prefill)])) 100) (dispatch [:chat-input-focus :input-ref]))))) diff --git a/src/status_im/chat/views/message/request_message.cljs b/src/status_im/chat/views/message/request_message.cljs index 27ea5d3c89..43975177a8 100644 --- a/src/status_im/chat/views/message/request_message.cljs +++ b/src/status_im/chat/views/message/request_message.cljs @@ -17,8 +17,7 @@ (defn set-chat-command [message-id command] (let [command-key (keyword (:name command)) - metadata (-> (:set-params command) - (assoc :to-message-id message-id))] + metadata {:to-message-id message-id}] (dispatch [:select-chat-input-command command metadata]))) (def min-scale 1) @@ -79,7 +78,7 @@ params (:params content) {:keys [command content]} (parse-command-request commands content) command (if (and params command) - (merge command {:set-params params}) + (merge command {:prefill (vals params)}) command)] [view st/comand-request-view [touchable-highlight