From 28f82558bfd7995cc66fbd44015a6b2f0747ada3 Mon Sep 17 00:00:00 2001 From: Juraj Martinka Date: Sat, 28 Jan 2017 16:44:29 +0100 Subject: [PATCH] fix #701: Redirect user to console when he tries to edit phone number in profile screen New event :phone-number-change-requested is dispatched and this is used to just redirect user to the console while automatically issuing :phone command. We don't allow to edit phone number directly in profile screen, because phone change requires entering sms confirmation code. --- src/status_im/profile/handlers.cljs | 11 ++++++++++- src/status_im/profile/screen.cljs | 14 ++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/status_im/profile/handlers.cljs b/src/status_im/profile/handlers.cljs index ea71c85c52..3b7b2b9a51 100644 --- a/src/status_im/profile/handlers.cljs +++ b/src/status_im/profile/handlers.cljs @@ -5,7 +5,8 @@ [status-im.utils.image-processing :refer [img->base64]] [status-im.i18n :refer [label]] [status-im.utils.handlers :as u :refer [get-hashtags]] - [taoensso.timbre :as log])) + [taoensso.timbre :as log] + [status-im.constants :refer [console-chat-id]])) (defn message-user [identity] (when identity @@ -35,3 +36,11 @@ 1 (dispatch [:open-image-picker]) :default)) :cancel-text (label :t/image-source-cancel)})))) + +(register-handler :phone-number-change-requested + ;; Switch user to the console issuing the !phone command automatically to let him change his phone number. + ;; We allow to change phone number only from console because this requires entering SMS verification code. + (u/side-effect! + (fn [db _] + (dispatch [:navigate-to :chat console-chat-id]) + (dispatch [:set-chat-command :phone])))) diff --git a/src/status_im/profile/screen.cljs b/src/status_im/profile/screen.cljs index b89767a1aa..afa24d8878 100644 --- a/src/status_im/profile/screen.cljs +++ b/src/status_im/profile/screen.cljs @@ -114,13 +114,6 @@ [status-view {:style (st/status-text (:height (r/state component))) :status status}])])}))) -(defn- navigate-to-phone-change - "Switch user to the console issuing the !phone command automatically to let him change his phone number." - [] - (dispatch [:navigate-to :chat console-chat-id]) - (dispatch [:set-chat-command :phone]) - ) - (defview profile [] [{whisper-identity :whisper-identity address :address @@ -163,13 +156,10 @@ [view st/profile-property-with-top-spacing [selectable-field {:label (label :t/phone-number) - :editable? false :value (if (and phone (not (str/blank? phone))) (format-phone-number phone) - (label :t/not-specified)) - ;; TODO: should this be changed? - :on-press navigate-to-phone-change}] + (label :t/not-specified))}] [view st/underline-container]] (when address @@ -223,7 +213,7 @@ :value (if (and phone (not (str/blank? phone))) (format-phone-number phone) (label :t/not-specified)) - :on-press navigate-to-phone-change}] + :on-press #(dispatch [:phone-number-change-requested])}] [view st/underline-container]] [view st/profile-property