This commit is contained in:
Roman Volosovskyi 2017-04-15 10:36:59 +03:00 committed by Roman Volosovskyi
parent 5b0e6642c2
commit 4843003749
3 changed files with 22 additions and 5 deletions

View File

@ -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))))
(assoc-in db [:chats chat-id :seq-argument-input-text] text))))

View File

@ -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

View File

@ -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