Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Conversation

@etoledom
Copy link
Contributor

@etoledom etoledom commented Jul 1, 2025

Closes GRA-170

This PR adds the buttons to upload new avatars from 3 different sources:

  • Camera
  • Photos app
  • Apple Playground (for supported devices)

Most of the types required come directly from the SDK, removing everything related to external custom image editor.

Problems encountered

1. Profile email needed for image upload (on the SDK side).

We need two breaking changes on the SDK. One of them was made here:

Automattic/Gravatar-SDK-iOS#792

The avatar upload request (as it was implemented) required the profile's Email, but what the backend is interested in is only the email's hash. So we should use PofileIdentifier instead.
As we don't have access to the email on the OAuth app, we must use the hash directly, so this change is required.

2. Erasing AvatarDetails type from the avatar upload return.

We tried too hard to hide Avatar information. AvatarDetails is public, but we erase it on the return of the avatar upload, and we return AvatarType instead which doesn't provide enough information for the model.

On this PR (so far) we are force-casting it, which is guaranteed to succeed, but ideally we need to get a AvatarDetails type from the upload.


Note: Automattic/Gravatar-SDK-iOS#792 has been updated to solve both problems


ScreenRecording_07-01-2025.22-39-02_1.mov

Test

  • Run the app on a device with Apple Intelligence enabled
  • Test the 3 new ways to upload images
  • Test failed uploads
    • Try retry an upload

@etoledom etoledom requested a review from pinarol July 1, 2025 20:43
@etoledom etoledom self-assigned this Jul 1, 2025
@wpmobilebot
Copy link

wpmobilebot commented Jul 1, 2025

App Icon📲 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
Build Number136
VersionPR #21
Bundle IDcom.gravatar.GravatarApp.prototype
Commit1197107
Installation URL5fdp2mpbo8pko
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Comment on lines 251 to 257
guard let avatar = try await avatarService.upload(
squareImage,
selectionBehavior: .selectUploadedImageIfNoneSelected(for: .hashID(profile.hash)),
accessToken: accessToken
) as? AvatarDetails else {
fatalError()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to return AvatarDetails from avatarService.upload()
This is a breaking change on the SKD

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we can start doing these sorts of changes on SDK's trunk branch. We had a list of things for a major version anyway and we have quite some deprecations piled up.
In the meantime if we need to fix anything we can do so in the release branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can depend point SDK dependency to a alpha/beta version or even to a commit, all better than having a fatalError() call in production.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all better than having a fatalError() call in production.

Yes I didn't mean to ship this fatal error to production, but I used it while we decide how to approach the SDK change.
As mentioned in the description:

On this PR (so far) we are force-casting it, which is guaranteed to succeed, but ideally we need to get a AvatarDetails type from the upload.

@etoledom
Copy link
Contributor Author

etoledom commented Jul 3, 2025

Automattic/Gravatar-SDK-iOS#792 solves both problems encountered, and I've updated this PR to implement those SDK API changes

Comment on lines 9 to 11
Text("Get a new look")
.font(.headline)
Text("It’s been 87 days since you updated your avatar.")
Copy link
Contributor

@pinarol pinarol Jul 3, 2025

Choose a reason for hiding this comment

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

We don't have localization yet but I think it would still be good to define these in a way that is easy for Glotpress to pick up in the futue, which is by declaring them as NSLocalizedString. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s been 87 days since you updated your avatar.

I know this is in the designs but we shouldn't put invalid static text I think. We don't have that info and it is unlikely we'll get it. Let's either replace it with a valid string or just remove this Text altogether until we know what to put here.

Copy link
Contributor

@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.

Just small comments otherwise looks good 🎉 I don't need to check again I think.

@etoledom etoledom merged commit a7a7744 into trunk Jul 3, 2025
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants