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

Extra profile refresh for the new users #615

Merged
merged 6 commits into from
Jan 22, 2025

Conversation

pinarol
Copy link
Contributor

@pinarol pinarol commented Dec 27, 2024

Closes #612

Description

Fixes the issue described in #612
This is to avoid the initial blank state of the profile view that a new user sees. When a user creates an account via WordPress.com they don't have a Gravatar profile yet so the Quick Editor shows blank fields initially. The Gravatar profile is created at the backend during the first avatars fetching, but we never refresh the client so the profile view remains blank and shows grey placeholders. This PR fixes that issue.

The issue is not too bad so I was on the fence of fixing/leaving it. Doing this only because I believe that the solution is not risky, it only adds an extra profile fetch call. But let me know if you think otherwise.

Testing Steps

Easiest way to test is using the Jetpack app

Check out WordPress-iOS trunk
Point the Gravatar dependency to this branch' latest commit
Run the Jetpack app
You can use a temp inbox like www.emailondeck.com to create an email
Logout and create a new user
Go to your inbox, verify the email (open the email verification link in incognito mode to isolate from your existing .com session otherwise it may not work)
Go to Me > My Profile > Add profile photo
Observe: The profile view does NOT show grey placeholder fields, instead, it shows the user's username and "View profile ->" button.

@pinarol pinarol added bug Something isn't working [Feature] Gravatar-QuickEditor Gravatar Quick Editor [Priority] Low labels Dec 27, 2024
@pinarol pinarol self-assigned this Dec 27, 2024
@wpmobilebot
Copy link

wpmobilebot commented Dec 27, 2024

Gravatar Prototype Build📲 You can test the changes from this Pull Request in Gravatar Prototype Build by scanning the QR code below to install the corresponding build.
App NameGravatar Prototype Build Gravatar Prototype Build
Build Number2041
Version1.0
Bundle IDcom.automattic.gravatar-sdk-demo-uikit.prototype-build
Commit43091a0
App Center BuildGravatar SDK Demo - UIKit #564
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@andrewdmontgomery
Copy link
Contributor

This looks like a reasonable workaround to me.

At first blush, at least, this seems like something the backend should handle better. It seems strange that the backend lazily creates the profile when /v3/me/avatars is fetched – but not when the actual profile is fetched. I wonder why? It seems like a backend error if the backend returns a 404 for a profile of a valid Gravatar account, regardless of how recently the account was created.

@pinarol
Copy link
Contributor Author

pinarol commented Jan 6, 2025

I thought it was because the /profiles/profile_id is an unauthenticated endpoint, but no, we add the access token to the request so there should not be an authorization issue. Let me check this internally, maybe we won't need this change at all.

@pinarol
Copy link
Contributor Author

pinarol commented Jan 7, 2025

Discussed with @jom, the /v3/profiles/... doesn't have an authenticated version atm. We add the token but it's ignored.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

I have reproduced the issue and tested this solution.

I think a small fix for this backend issue is good to have. In my experience, though it's not a blocker for the user, it might appear odd for some, but probably many won't really pay attention to it.

Still it seems like a malfunction by our SDK so I'd vote for merging this fix.

This is how the issue looks like:

CleanShot.2025-01-20.at.12.33.14.mp4

I also tested setting an image to see if the whole Profile card updates (magically). If it were the case, this fix wouldn't be needed IMO, but it does not refresh, only the avatar.

CleanShot.2025-01-20.at.12.39.57.mp4

Finally, while testing this branch, the Profile card loads as expected 🎉

CleanShot.2025-01-20.at.12.59.40-converted-converted.mp4

I saw first a small blink where the card shows the placeholder labels:

To then finally load the user info:

But most importantly, what I noticed is that the avatar from the Profile won't change after selecting an avatar (shown in the last video).

I have two thoughts about this:

  • If the Profile Card loads the placeholder text in the labels instead of keeping the gray loading state, maybe is much less obvious that it is an error, and we can keep it this way.

  • The avatar selection no showing on the Profile card is a blocker to merge this PR. But I'd vote for a simpler solution if possible which I mentioned in the previous point.

@etoledom
Copy link
Contributor

After restarting Jetpack, the problem persisted, but I continued changing and testing and it eventually started showing the change on the card:

Not sure if the problem is on the SDK, backend, or even Jetpack cache.

@pinarol
Copy link
Contributor Author

pinarol commented Jan 20, 2025

But most importantly, what I noticed is that the avatar from the Profile won't change after selecting an avatar (shown in the last video).

I noticed the same issue and I think fixed it by increasing the delay here in the release branch.

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
I'll rebase this on it. Not ideal though, I should make an enhancement on the AvatarView so we don't need this workaround anymore.

@pinarol pinarol force-pushed the wppinar/refresh-profile-on-upload branch from fb8d840 to 343d1b0 Compare January 20, 2025 14:06
@pinarol pinarol changed the base branch from trunk to release/3.2.0 January 20, 2025 14:06
@pinarol
Copy link
Contributor Author

pinarol commented Jan 22, 2025

I made this PR #644 to remove the workaround I mentioned here #615 (comment)

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

The problem mentioned before seems to be resolved:

CleanShot.2025-01-22.at.11.59.08.mp4

The user profile is loaded on the first opening of the quick editor, and the avatar image updates as expected 🎉

@pinarol pinarol merged commit a82a1d0 into release/3.2.0 Jan 22, 2025
14 checks passed
@pinarol pinarol deleted the wppinar/refresh-profile-on-upload branch January 22, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working [Feature] Gravatar-QuickEditor Gravatar Quick Editor [Priority] Low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Profile needs refreshing after the first avatar fetch on a new account
4 participants