Skip to content
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

Changed Profile Picture save on click of Save button #7366

Merged
merged 16 commits into from
Feb 8, 2022

Conversation

mananjadhav
Copy link
Collaborator

@mananjadhav mananjadhav commented Jan 22, 2022

Details

  • For ProfilePage we were saving it immediately after uploading, which was a bit inconsistent from Workspace. To have a uniform user experience, with this PR, now it'll update the profile picture on click of the Save button.

Fixed Issues

$ #7015

Tests

  1. Uploading a new profile photo
  2. Save button being disabled if the picture is not updated
  3. Removing the existing profile picture
  4. Reloading the screens without clicking Save (or going back)
  • Verify that no errors appear in the JS console

QA Steps

  1. Go to the settings and click on Avatar
  2. In the sidebar click on the profile avatar
  3. Click on the edit (or camera) icon of Avatar and upload the photo
  4. Ensure it doesn't upload the photo
  5. Click on Save and verify that the avatar is saved
  • Verify that no errors appear in the JS console

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

web-profile-picture-update.mov

Mobile Web

mweb-profile-image-update_cAd3mnGv.mp4

Desktop

desktop-profile-image-update_RIANWcN4.mp4

iOS

ios-profile-image-update.mp4

Android

android-profile-image-update_c9u6RQul.mp4

@mananjadhav mananjadhav marked this pull request as ready for review January 22, 2022 10:07
@mananjadhav mananjadhav requested a review from a team as a code owner January 22, 2022 10:07
@MelvinBot MelvinBot removed the request for review from a team January 22, 2022 10:07
@mananjadhav
Copy link
Collaborator Author

@rushatgabhane @AndrewGable I have got one question. From the UX standpoint, if you see the toast message shows while the image is being uploaded at the background. Because we stay at the same page I don't think so it needs any handling.

But do let me know if you want to move setAvatar and deleteAvatar inside PersonalDetails.setPersonalDetails call.

@rushatgabhane
Copy link
Member

Proposal hasn't been given a green yet, so I'll wait until that's done before PR review.

@mananjadhav
Copy link
Collaborator Author

Ohh sorry for the confusion, I took this assignment comment as for hire #7015 (comment)

do you want me to close the PR ?

@rushatgabhane
Copy link
Member

That's okay. Umm, convert it to a draft I guess

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, minor change suggested.

I'm fine with the growl shown while the image is uploading. Because in case of a large image/slow network, it'll be confusing to see the success message long after exiting ProfilePage.

@rushatgabhane
Copy link
Member

@mananjadhav The save button isn't disabled after uploading new avatar.

1.New.Expensify.-.Google.Chrome.2022-01-24.15-55-54.mp4

@mananjadhav mananjadhav marked this pull request as ready for review January 25, 2022 18:11
@botify botify requested a review from rushatgabhane January 25, 2022 18:11
@mananjadhav
Copy link
Collaborator Author

@rushatgabhane I tried updating the state of avatarURL based on the props change, but there's a small flicker. Are we fine with that?

Screen.Recording.2022-01-25.at.11.06.22.PM.mov

@rushatgabhane
Copy link
Member

Hmm, that's not ideal. We should fix the flicker.

@rushatgabhane
Copy link
Member

@mananjadhav please merge main into this branch

@mananjadhav
Copy link
Collaborator Author

mananjadhav commented Jan 28, 2022

@rushatgabhane Sorry for the delay, been unwell. I will resolve the conflict when working on the flicker change.

I have thought about the flicker but I have a few questions.

It should disable only if the image is successfully uploaded right? With this if I consider then on componentDidUpdate, the URL changes from a local imageUri to remote URL of the avatar, with this change, it will flicker. In Workspace the thing is the image is uploaded, the URL is returned and that is what gets set hence we don't see the flicker.

Now either I can use a flag/condition, which probably updates on profile image upload complete, say avatarImg !== null && this.props.isAvatarUpload === false,

or I store a state variable like isAvatarUpdateComplete, which gets set if the if (this.props.myPersonalDetails.avatar !== this.state.avatarPreviewURL && this.props.myPersonalDetails.avatar !== prevProps.myPersonalDetails.avatar) {

and use that to disable the button.

Thoughts?

@rushatgabhane
Copy link
Member

rushatgabhane commented Jan 28, 2022

Hi @mananjadhav, that's okay. I hope you're well now :)

It should disable only if the image is successfully uploaded right?

I don't think that's a good idea. If the button isn't disabled, the user might press it again.
Image upload takes time and we shouldn't resend those requests.

@rushatgabhane
Copy link
Member

rushatgabhane commented Jan 29, 2022

I'll get back to you regarding flicker.
Meanwhile, let me know if you're able to figure something out.

@mananjadhav
Copy link
Collaborator Author

I don't think that's a good idea. If the button isn't disabled, the user might press it again.

@rushatgabhane I guess I didn't elaborate on all cases. I've updated the code of what I was explaining and it seems to be working. Thoughts?

@rushatgabhane
Copy link
Member

Thanks for the update @mananjadhav, the save button isn't disabled until upload is complete.

Screencast.from.30-01-22.05-24-20.PM.+03.mp4

I can't find a way around the flicker without waiting for the upload either.

Sorry to drag this, but let's revert and go to the previous implementation?
(Button disable immediately)

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mananjadhav I found a bug.

  1. Remove profile photo.
  2. Click Save button.
  3. Change timezone.

Expected result: Save button is enabled, and has styling of enabled button (100% opacity).

Actual result: Save button is enabled, but it has styling of disabled button (50% opacity).

Screen.Recording.2022-01-31.at.5.14.30.AM.mov

@mananjadhav
Copy link
Collaborator Author

@rushatgabhane I had specifically tested this piece and I am not able to reproduce it. Can you help with the reproduction steps?

Here's the video while I did the testing.

profile-image-update-test.mp4

@rushatgabhane
Copy link
Member

@mananjadhav hmm, this is interesting. You're following the correct steps.

I retested and I'm facing this issue on all platforms :(
I'm able to replicate it on a different laptop too.

@mananjadhav
Copy link
Collaborator Author

I didn't check on a different device, but I tested it all on platforms. I did all my testing on Chrome earlier but I saw your screencast is in Safari, so I tested on Safari as well.

@rushatgabhane
Copy link
Member

rushatgabhane commented Jan 31, 2022

@mananjadhav thanks!

@AndrewGable could you please help us verify this? Because it isn't reproducible for Manan.

@rushatgabhane
Copy link
Member

rushatgabhane commented Jan 31, 2022

@mananjadhav This is weird, but for me the Growl message is shown twice. I know this isn't the case for you as seen in the video above.

I clicked only once, branch is on latest commit with nothing to commit, tested on all platforms and 2 laptops.

I think there's something wrong on my end that I can't figure out, let's see what @AndrewGable says :)
Again, thanks for your patience!

Screen.Recording.2022-01-31.at.9.37.36.AM.mov

@mananjadhav
Copy link
Collaborator Author

@AndrewGable Can you help me and @rushatgabhane with this one?

@rushatgabhane
Copy link
Member

@mananjadhav I just tested it on a third device. I can consistently repro this bug and Growl message shown twice.

Let's revert to - #7366 (comment)
It'll keep the code easy to understand too. What do you think?

I'm on the latest commit

@mananjadhav
Copy link
Collaborator Author

Hmm, 🤔 Let me probably try this again.

@rushatgabhane
Copy link
Member

Any updates? Thanks

@mananjadhav
Copy link
Collaborator Author

@rushatgabhane Thanks for being persistent with this. I was able to reproduce this and just pushed a fix for this.

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewGable LGTM! 🎉️ Tests well on all platforms and all bugs are resolved.

Thanks so much @mananjadhav for making the changes.

@AndrewGable AndrewGable merged commit a517f53 into Expensify:main Feb 8, 2022
@OSBotify
Copy link
Contributor

OSBotify commented Feb 8, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Feb 9, 2022

🚀 Deployed to staging by @AndrewGable in version: 1.1.38-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Julesssss in version: 1.1.38-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@NikkiWines
Copy link
Contributor

Looks like this caused a regression @mananjadhav @AndrewGable - #7784

@mananjadhav
Copy link
Collaborator Author

On it

// Recalculate logins if loginList has changed
if (this.props.user.loginList === prevProps.user.loginList) {
if (this.props.user.loginList !== prevProps.user.loginList) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this ever be false? I'm pretty sure in JS you can never check if arrays (objects) are equal with === or !== because they're pointers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants