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

QuickEditor: Refreshing all info when no avatar selected and a new one is uploaded #381

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

hamorillo
Copy link
Contributor

@hamorillo hamorillo commented Oct 10, 2024

Closes #380

Description

When a new avatar is uploaded into a Gravatar account with no avatar selected, the backend automatically uses that image as the default avatar.

We need to reflect that in the QE UI. We can hardcode the changes in the code, modifying the uiState as required. However, if the backend behavior changes at some point, all previous versions of the QE will show the wrong status of the Gravatar account.

To mitigate that situation, we will refresh all data from the backend if an image is uploaded and no previous avatar is selected.

What do you think about this approach? Do you think it's worth it to refresh everything or assume the risk and modify the uiState locally, expecting the backend to do the same?

Note: I'll add some unit tests before merging if we decide to go this way.

Testing Steps

  1. Using an account with no avatar selected
  2. Upload a new image using the QE
  3. Verify you see, after reloading, the new image as the selected image.

When a new avatar is uploaded into a Gravatar account with no avatar selected, the backend automatically uses that image as the default avatar.

We need to reflect that in the QE UI. We can hardcode the changes in the code, modifying the uiState as required. However, if the backend behavior changes at some point, all previous versions of the QE will show the wrong status of the Gravatar account.

To mitigate that situation, if an image is uploaded and no previous avatar is selected, we will refresh all data from the backend.
@hamorillo hamorillo added the bug Something isn't working label Oct 10, 2024
@hamorillo hamorillo added this to the 2.0.0 milestone Oct 10, 2024
@hamorillo hamorillo marked this pull request as ready for review October 10, 2024 11:04
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 10, 2024

📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App Name Gravatar Demo
Commit0892675
Direct Downloadgravatar-demo-prototype-build-pr381-0892675.apk

Comment on lines +151 to +152
_uiState.update { AvatarPickerUiState(email, avatarPickerContentLayout) }
refresh()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's completely reasonable to refresh the content like you said, to future proof in case of backend changes, but I wonder if we really have to clean the whole state?

Could we do this refresh action as part of the uploading indicator? With the current code, we hide the whole list, the profile card is recomposed fully and that seems like a lot to select an avatar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we do this refresh action as part of the uploading indicator? With the current code, we hide the whole list, the profile card is recomposed fully and that seems like a lot to select an avatar.

I don't think it's easy to keep the uploading indicator until the fetchAvatars finishes, at least reusing the current methods, but I'll try to improve it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct, you have to use suspend functions that won't start a new coroutine. We do have one like that to fetch avatars but not for the profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quick Editor: The selected avatar isn't shown after a new upload when there wasn't a previously selected one.
3 participants