-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing bug #1706 edit profile from drawer resetting username to default #1733
Conversation
67e5a62
to
81b407a
Compare
81b407a
to
71b0aca
Compare
(close-drawer) | ||
(when-let [save-event @(rf/subscribe [:my-profile.drawer/save-event])] | ||
(rf/dispatch [save-event])) | ||
(rf/dispatch [:navigate-to :accounts])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both block of code are very similar. Maybe introduce a function?
[view | ||
[ci/chat-icon (:photo-path account) {:size 52}]]]) | ||
(letsubs [account [:get-current-account]] | ||
[touchable-opacity {:on-press #(navigate-to-profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just navigate-to-profile
?
{:on-press (fn [] | ||
(close-drawer) | ||
(rf/dispatch [:navigate-to :my-profile]))} | ||
{:on-press #(navigate-to-profile)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
{:on-press (fn [] | ||
(close-drawer) | ||
(rf/dispatch [:navigate-to :accounts]))} | ||
{:on-press #(navigate-to-accounts)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
{:keys [name public-key]} (get-current-account db)] | ||
{:db (cond-> db | ||
(not default-name) (assoc :my-profile/default-name (gfycat/generate-gfy public-key)) | ||
:always (assoc-in [:my-profile/drawer :name] name))}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am more used to see :else
. I don't know if we have such convention in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used true
in some places, but i like :always
much more than true
tbh. And :else
isn't quite correct here, because other branches can be executed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed :always
is more appropriate for cond->
.
:<- [:get-current-account] | ||
:<- [:get :my-profile/drawer] | ||
(fn [[current-account profile] [_ k]] | ||
(or (get profile k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both blocks are similar. Introduce a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
(reg-sub :my-profile.drawer/valid-name? | ||
:<- [:get :my-profile/drawer] | ||
(fn [profile] | ||
(get profile :valid-name? true))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how to introduce a function there it is subscriptions, the idea is that it only recomputes when the profile or drawer changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or (get ..) (get ..))
is used for 2 subscriptions. This part could be abstracted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is worth trading 2 lines for a function and an indirection
(assoc-in [:my-profile/profile :edit-status?] edit-status?) | ||
(update-in [:my-profile/profile] | ||
#(merge (select-keys (get-current-account db) db/account-profile-keys) %)))] | ||
{:db new-db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignment in map
71b0aca
to
1951698
Compare
#1746 Default username becomes empty if open Profile screen [bug/username-changed-to-default] is introduced by this PR |
1951698
to
d93d300
Compare
Wrong QR code (picture - if scan then no public key is recognized), no username and no avatar is shown on Show QR opened on Profile screen. Same issue for Show QR of the Public key and Address. Test session (from 00:50) https://app.testfairy.com/projects/4803622-status/builds/6498278/sessions/3/?accessToken=Sw2XZ7nnooCNL6a49kGzIbIeia4 Steps:
On both Android and iOS, build #6 for |
d93d300
to
f34c98a
Compare
The QR code bug was caused by a missing import: With the refactoring the navigation code got moved from events to navigation namespace and navigation namespace has to be imported in events otherwise the code is never there. In this case there was data to be pre-loaded when opening the qr-code modal window that was not anymore. |
f34c98a
to
deb1dbb
Compare
@@ -34,60 +34,70 @@ | |||
(defn open-drawer [] (.openDrawer @drawer-atom)) | |||
(defn close-drawer [] (.closeDrawer @drawer-atom)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about calling this open-drawer!
to signify side effect? Same with close-drawer
and possibly save-profile
.
status [:my-profile.drawer/get :status]] | ||
(let [placeholder (i18n/label :t/update-status)] | ||
[view st/status-container | ||
(if edit-status? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider breaking these two vectors out into util fns so if statement is clear, no need for newline then
@@ -6,6 +6,8 @@ | |||
[status-im.constants :as constants] | |||
[status-im.utils.homoglyph :as homoglyph])) | |||
|
|||
(def account-profile-keys [:name :photo-path :status]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always used as a cursor? If so I think we should indicate it as such, e.g. photo-status-path
or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a cursor it is a list of keys to select from the profile when extracting profile
:on-change-text #(dispatch [:set-in [:my-profile/edit :name] %])}]])) | ||
[text-input-with-label | ||
{:label (label :t/name) | ||
:default-value profile-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align
[react/view styles/edit-profile-status | ||
[react/scroll-view | ||
(if edit-status? | ||
[react/text-input | ||
{:ref #(reset! input-ref %) | ||
:auto-focus edit-status? | ||
{:auto-focus (if edit-status? true false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this just edit-status?
would consider renaming it to auto-focus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about this one, the focus can be on something else, auto-focus in the app-db wouldn't be really helpful to figure our what it implies. Here it means user is editing the status field.
:<- [:get-current-account] | ||
:<- [:get :my-profile/drawer] | ||
(fn [[current-account profile] [_ k]] | ||
(or (get profile k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
{:db new-db | ||
:dispatch-n [[:check-status-change status] | ||
[:account-update {:status status}]]})))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would like to have :check-status-change
and :account-update
refactored into pure functions and just call them there instead of the dispatch, but I understand it's not focus of this PR and it's another module (accounts
), so it can be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's an old part of the code where there is still ui/side-effects
New issue: #1769 picture is not saved as avatar if use Capture. After tap on camera icon Edit profile screen is shown but avatar contains old default picture |
1ad5d20
to
9044db9
Compare
9044db9
to
4ced8d4
Compare
4ced8d4
to
3686067
Compare
3686067
to
26db180
Compare
#1706
Summary:
Username is changed to default if Profile screen was opened and user taps on status and username fields
The pull request solves the bug by reworking the way state is stored for profile editing.
Before the drawer profile was in local state and the profile was in app-db. This PR puts everything into the app-db and simplifies future UX changes by defining small events for each user action.
Tests are also adapted to reflect the changes (only simple cases of status changes, maybe in the future some generative testing could be used to check more complex events, or at least more cases could be added). I also removed the phone change test because it was not a phone change test
Behaviors tested on Android emulator
Additional UX improvements tested:
Steps to test:
status: ready