From 3578eed91299439da903cb230a7116b6e31d5620 Mon Sep 17 00:00:00 2001 From: angusiguess Date: Mon, 2 Oct 2017 13:02:55 -0300 Subject: [PATCH] Update navigation for QR scan Factor copy/paste to use choose-recipient Change assoc to an update Set name to nil --- .../ui/screens/wallet/choose_recipient/views.cljs | 4 ++-- src/status_im/ui/screens/wallet/send/events.cljs | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs index d7fe58c55b..272267ed66 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/views.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/views.cljs @@ -45,7 +45,7 @@ [react/touchable-highlight {:style (styles/recipient-touchable true) :on-press #(react/get-from-clipboard (fn [clipboard] - (re-frame/dispatch [:choose-recipient clipboard])))} + (re-frame/dispatch [:choose-recipient clipboard nil])))} [react/view {:style styles/recipient-button} [react/text {:style styles/recipient-button-text} (i18n/label :t/wallet-address-from-clipboard)] @@ -93,6 +93,6 @@ (let [data (-> code .-data (string/replace #"ethereum:" ""))] - (re-frame/dispatch [:choose-recipient data])))}] + (re-frame/dispatch [:choose-recipient data nil])))}] [viewfinder camera-dimensions]] [recipient-buttons]])) diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index ddf69fb412..6d719449b0 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -37,17 +37,20 @@ ;;;; Handlers -(handlers/register-handler-db +(defn choose-address-and-name [db address name] + (update db :wallet/send-transaction assoc :to-address address :to-name name)) + +(handlers/register-handler-fx :choose-recipient - (fn [db [_ recipient]] - (assoc-in db [:wallet :send :recipient] recipient))) + (fn [{:keys [db]} [_ address name]] + (let [{:keys [view-id]} db] + (cond-> {:db (choose-address-and-name db address name)} + (= :choose-recipient view-id) (assoc :dispatch [:navigate-back]))))) (handlers/register-handler-fx :wallet-open-send-transaction (fn [{db :db} [_ address name]] - {:db (update db :wallet/send-transaction - #(assoc % :to-address address - :to-name name)) + {:db (choose-address-and-name db address name) :dispatch-n [[:navigate-back] [:navigate-back]]}))