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.
This commit is contained in:
Juraj Martinka 2017-01-28 16:44:29 +01:00 committed by Roman Volosovskyi
parent 71ba979671
commit 28f82558bf
2 changed files with 12 additions and 13 deletions

View File

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

View File

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