fix #1414 by adding necessary data to bot-db

This commit is contained in:
Roman Volosovskyi 2017-07-13 12:05:50 +03:00
parent ac699e3320
commit 1a056d0256
1 changed files with 9 additions and 10 deletions

View File

@ -47,7 +47,8 @@
(fn [db [_ bridge]] (fn [db [_ bridge]]
(assoc db :webview-bridge bridge))) (assoc db :webview-bridge bridge)))
(defn contacts-click-handler [{:keys [whisper-identity] :as contact} action params] (defn contacts-click-handler
[{:keys [whisper-identity] :as contact} action params]
(dispatch [:navigate-back]) (dispatch [:navigate-back])
(when action (when action
(if (= contact :qr-scan) (if (= contact :qr-scan)
@ -55,22 +56,20 @@
(dispatch [:show-scan-qr :webview-address-from-qr]) (dispatch [:show-scan-qr :webview-address-from-qr])
(dispatch [:navigate-to-modal :qr-code-view {:qr-source :whisper-identity (dispatch [:navigate-to-modal :qr-code-view {:qr-source :whisper-identity
:amount? true}])) :amount? true}]))
(dispatch [:chat-with-command whisper-identity action params])))) (dispatch [:chat-with-command whisper-identity action
(assoc params :contact contact)]))))
(register-handler ::send-command (register-handler ::send-command
(u/side-effect! (u/side-effect!
(fn [{:keys [current-chat-id] :as db} [_ command-key params]] (fn [{:keys [current-chat-id] :as db}
(let [command (get-in db [:contacts current-chat-id :commands command-key]) [_ command-key {:keys [contact amount]}]]
command-input {:content "0" (let [command (get-in db [:contacts current-chat-id :commands command-key])]
:command command (dispatch [:set-in [:bot-db current-chat-id :public :recipient] contact])
:parameter-idx 0
:params {"amount" (:amount params)}
:to-message-id nil}]
(dispatch [:proceed-command (dispatch [:proceed-command
{:command command, {:command command,
:metadata nil, :metadata nil,
:args [(str (:amount params))]} :args [(get contact :name) amount]}
current-chat-id]))))) current-chat-id])))))
(defn chat-with-command (defn chat-with-command