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

Integrate Gravatar Quick Editor #23729

Open
wants to merge 25 commits into
base: trunk
Choose a base branch
from

Conversation

pinarol
Copy link
Contributor

@pinarol pinarol commented Oct 30, 2024

Fixes #

Integrates the Gravatar Quick Editor into Jetpack.
Changes are behind the remote feature flag: gravatar_quick_editor

RPReplay_Final1730303727.MP4
RPReplay_Final1730303545.MP4

Technical Details

The new structure depends on the Quick Editor's update callback and fires a notification GravatarQEAvatarUpdateNotification. The UI components that render the avatar subscribe to that notification. Once received, they fetch the latest version of the avatar from the BE. To achieve this we introduce a way to forceRefresh the avatar, which wasn't present before. To achieve forceRefresh we add a cache buster query parameter otherwise the backend cache gets in the way and the latest version of the avatar can't be fetched.

To test:

Enable the feature flag "Gravatar Quick Editor" in Me > App Settings > Debug > Feature Flags (It's enabled by default in DEBUG config)
Log out from the Jetpack app
Log in with a new email (Highly recommend getting a temp email via https://tempmail.so/us , you should go to your inbox in your mobile device since the login depends on a magic link)
Use the email magic link to continue to the app
Observe: You landed on the signup epilogue, the avatar placeholder has a + on it and tapping on the avatar opens the Quick Editor.
Upload & change the avatar via the Quick Editor
Observe: The avatar on the signup page also gets updated
Close the Quick Editor
Continue to the app

Go to Me > My Profile
Tap either on the avatar or on the "Update profile photo" button
Observe: Quick Editor opens
Upload & change the avatar via the Quick Editor
Observe: The avatars on the main app gets updated as well (the one on the profile header, and the "Me" tab bar item at the bottom)

Appearance Test
Go to Me > App Settings > Appearance
Switch the appearance
Go to Me > My Profile
Tap either on the avatar or on the "Update profile photo" button
Observe: Quick Editor opens and the appearance matched with the app.

Disable the feature flag "Gravatar Quick Editor" in Me > App Settings > Debug > Feature Flags

Repeat the tests ☝️
This time instead of the Gravatar Quick Editor you should observe that the system photo picker appears and the selected image is uploaded & set as the avatar.

Regression Notes

  1. Potential unintended areas of impact
    The existing upload flow

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Tested with the feature flag off

  3. What automated tests I added (or what prevented me from doing so)
    x

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@pinarol pinarol added this to the 25.6 milestone Oct 30, 2024
@pinarol pinarol self-assigned this Oct 30, 2024
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Oct 30, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23729-565fd9a
Version25.4.2
Bundle IDorg.wordpress.alpha
Commit565fd9a
App Center BuildWPiOS - One-Offs #11026
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Oct 30, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23729-565fd9a
Version25.4.2
Bundle IDcom.jetpack.alpha
Commit565fd9a
App Center Buildjetpack-installable-builds #10066
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Add email check when handling the notification

`GravatarQEAvatarUpdateNotification`
# Conflicts:
#	WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift
@pinarol pinarol added the Gravatar Gravatar SDK related updates label Oct 31, 2024
@pinarol pinarol marked this pull request as ready for review October 31, 2024 16:19
@pinarol
Copy link
Contributor Author

pinarol commented Oct 31, 2024

cc: @kean @crazytonyli

Task {
// Purge the cache otherwise the old avatars remain around.
await ImageDownloader.shared.clearURLSessionCache()
await ImageDownloader.shared.clearMemoryCache()
Copy link
Contributor

Choose a reason for hiding this comment

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

Purging all cache entries seems a bit aggressive. Would only removing the cached image for email work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite being connected to the same email, avatars scattered throughout the app have usually different URLs depending on the query parameters like size, default image option, rating etc.

And unfortunately URLCache or NSCache doesn't give us chance to iterate over the cache keys and filter based on host and path. We need to know the exact URL to remove an entry which we don't.

Alternatively, we can remove these calls altogether but this causes some avatars to remain old in different places of the app which looks inconsistent and faulty. Also, killing & reopening the app can bring in the old avatar since URLCache has a disk cache. So I recommend keeping these purge operations but let me know if you prefer otherwise.

# Conflicts:
#	WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift
#	WordPress/WordPress.xcodeproj/project.pbxproj
@pinarol pinarol modified the milestones: 25.6, 25.7 Nov 11, 2024
Copy link
Contributor Author

@pinarol pinarol left a comment

Choose a reason for hiding this comment

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

Thanks for the review @crazytonyli 🙇 This is ready for another look. (I was AFK last week so this is a bit of a late response)

Task {
// Purge the cache otherwise the old avatars remain around.
await ImageDownloader.shared.clearURLSessionCache()
await ImageDownloader.shared.clearMemoryCache()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite being connected to the same email, avatars scattered throughout the app have usually different URLs depending on the query parameters like size, default image option, rating etc.

And unfortunately URLCache or NSCache doesn't give us chance to iterate over the cache keys and filter based on host and path. We need to know the exact URL to remove an entry which we don't.

Alternatively, we can remove these calls altogether but this causes some avatars to remain old in different places of the app which looks inconsistent and faulty. Also, killing & reopening the app can bring in the old avatar since URLCache has a disk cache. So I recommend keeping these purge operations but let me know if you prefer otherwise.

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not so sure about these changes. @kean Can you have a look please?

@crazytonyli
Copy link
Contributor

@pinarol Thanks for addressing my comments. They look good to me. I'm not familiar with the image downloading implementation, and asked Alex to have to a look. ⬆️

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

Successfully merging this pull request may close these issues.

3 participants