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

Merge Ratings into AtlText #595

Conversation

andrewdmontgomery
Copy link
Contributor

@andrewdmontgomery andrewdmontgomery commented Dec 11, 2024

Description

Now that #589 (QE: Avatar Rating) PR just merged into trunk, this merges trunk back into #590 (AltText Editor).

  • merges trunk (including the new Avatar Rating capability)
  • Adds .altText into the new Menu structure
  • Renames setRating(_ rating: AvatarRating, for avatar: AvatarImageModel) async --> update(_ avatar: AvatarImageModel, rating: AvatarRating) async -> Bool
  • Makes the update() functions @discardableResult
    • AvatarService.update(::::)
    • AvatarPickerViewModel.update(_: altText)
    • AvatarPickerViewModel.update(_: rating)
  • Removes the ProfileService.setRating(:::) function in favor of the AvatarService.update(::::) function in the AltText PR
  • Updates related unit tests

Testing Steps

  • Make sure the AltText changes are still intact
  • Make sure the AltText and Rating menu items work as expected

@dangermattic
Copy link
Collaborator

1 Error
🚫 You need to add at least one label to this PR

Generated by 🚫 Danger

@wpmobilebot
Copy link

wpmobilebot commented Dec 11, 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 Number1853
Version1.0
Bundle IDcom.automattic.gravatar-sdk-demo-uikit.prototype-build
Commit175f490
App Center BuildGravatar SDK Demo - UIKit #460
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

package func update(_ altText: String?, rating: AvatarRating?, avatarID: String, accessToken: String) async throws {
@discardableResult
package func update(
_ altText: String?,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
_ altText: String?,
altText: String?,

Now that we have multiple parameters that we can "update", I think the calling site might read better if we name the first parameter. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with this change 👍

rating: AvatarRating?,
avatarID: String,
accessToken: String
) async throws -> 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.

We don't currently use this return data. But since the API defines a return type for this, I thought we probably should return it, and make it @discardableRersult.

That does mean that if we can't decode it (which I would expect to be quite rare since it would be a backend error that breaks the API), this will throw an error.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually, if (when?) we make this part of the API public, we can follow the pattern of:

public update(::::) --> AvatarType
package update(::::) --> Avatar

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! 👍

@@ -337,6 +338,7 @@ class AvatarPickerViewModel: ObservableObject {
await profile
}

@discardableResult
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reasonable? Or do we want to check the result?

@etoledom etoledom self-requested a review December 11, 2024 20:09
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.

Looks super good!
Thank you for helping with the merge 🙏

rating: AvatarRating?,
avatarID: String,
accessToken: String
) async throws -> Avatar {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! 👍

package func update(_ altText: String?, rating: AvatarRating?, avatarID: String, accessToken: String) async throws {
@discardableResult
package func update(
_ altText: String?,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with this change 👍

@andrewdmontgomery andrewdmontgomery merged commit 86d708c into etoledom/alt-text-editor Dec 11, 2024
6 of 9 checks passed
@andrewdmontgomery andrewdmontgomery deleted the andrewdmontgomery/etoledom/alt-text-editor branch December 11, 2024 21:36
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.

4 participants