diff --git a/src/status_im/chat/handlers/input.cljs b/src/status_im/chat/handlers/input.cljs index 39dcc41d36..f05977762b 100644 --- a/src/status_im/chat/handlers/input.cljs +++ b/src/status_im/chat/handlers/input.cljs @@ -150,7 +150,7 @@ (dispatch [:prepare-message data])))))) (handlers/register-handler - ::proceed-command + :proceed-command (handlers/side-effect! (fn [db [_ command chat-id]] (let [after-validation #(dispatch [::request-command-data @@ -249,7 +249,7 @@ (if (:command chat-command) (if (= :complete (input-model/command-completion chat-command)) (do - (dispatch [::proceed-command chat-command chat-id]) + (dispatch [:proceed-command chat-command chat-id]) (dispatch [:clear-seq-arguments chat-id])) (let [text (get-in db [:chats chat-id :input-text])] (dispatch [:set-chat-ui-props :sending-in-progress? false]) @@ -315,4 +315,4 @@ :set-chat-seq-arg-input-text (fn [{:keys [current-chat-id] :as db} [_ text chat-id]] (let [chat-id (or chat-id current-chat-id)] - (assoc-in db [:chats chat-id :seq-argument-input-text] text)))) \ No newline at end of file + (assoc-in db [:chats chat-id :seq-argument-input-text] text)))) diff --git a/src/status_im/chat/handlers/webview_bridge.cljs b/src/status_im/chat/handlers/webview_bridge.cljs index 690f0eec24..2328f1dc86 100644 --- a/src/status_im/chat/handlers/webview_bridge.cljs +++ b/src/status_im/chat/handlers/webview_bridge.cljs @@ -58,9 +58,26 @@ (dispatch [:chat-with-command whisper-identity action params])))) +(register-handler ::send-command + (u/side-effect! + (fn [{:keys [current-chat-id] :as db} [_ command-key params]] + (let [command (get-in db [:chats current-chat-id :commands command-key]) + command-input {:content "0" + :command command + :parameter-idx 0 + :params {"amount" (:amount params)} + :to-message-id nil}] + (dispatch [:proceed-command + {:command command, + :metadata nil, + :args [(str (:amount params))]} + current-chat-id]))))) + (defn chat-with-command [_ [_ whisper-identity command-key params]] (dispatch [:remove-contacts-click-handler]) + (dispatch [:add-chat-loaded-callback whisper-identity + #(dispatch [::send-command command-key params])]) (dispatch [:start-chat whisper-identity])) (register-handler :chat-with-command diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 559664da86..6b1e51e9ca 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -27,8 +27,8 @@ (register-sub :chat-ui-props (fn [db [_ ui-element chat-id]] - (let [chat-id (or chat-id (:current-chat-id @db))] - (reaction (get-in @db [:chat-ui-props chat-id ui-element]))))) + (let [current-chat-id (subscribe [:get-current-chat-id])] + (reaction (get-in @db [:chat-ui-props (or chat-id @current-chat-id) ui-element]))))) (register-sub :chat-input-margin