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

Use Gravatar.ImageCaching protocol instead of defining our own #146

Conversation

andrewdmontgomery
Copy link

@andrewdmontgomery andrewdmontgomery commented Feb 22, 2024

This updates the module so that it implements (and re-exports) the Gravatar.ImageCaching protocol instead of a local protocol that conforms to it.

Note that since this preserves the WordPressUI-iOS public interfaces, no changes to WordPress-iOS should be necessary.

This should be tested via the WordPress-iOS PR that requires it:
wordpress-mobile/WordPress-iOS#22663

Checkout this branch of WordPressUI-iOS
Checkout Gravatar branch: Automattic/Gravatar-SDK-iOS#50
Checkout WordPress-iOS task/gravatar-integration branch: https://github.com/wordpress-mobile/WordPress-iOS/tree/task/gravatar-integration

Follow the steps mentioned here: wordpress-mobile/WordPress-iOS#22543 (comment)


  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

Comment on lines -176 to -180
public protocol ImageCaching: GravatarImageCaching {
func setImage(_ image: UIImage, forKey key: String)
func getImage(forKey key: String) -> UIImage?
}

Copy link
Author

Choose a reason for hiding this comment

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

Is there a reason we were creating our own protocol in WPUI that conforms to the Gravatar protocol? After the renaming, this got tricky. And it seemed to make sense to drop this in favor of using the Gravatar.ImageCaching protocol.

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably existed before Gravatar SDK, and now we have the same name for the same definition of protocol.
I agree, we can drop it unless it's used somewhere else as argument independently from Gravatar, which doesn't seem to be the case 🤔

Copy link
Contributor

@pinarol pinarol Feb 23, 2024

Choose a reason for hiding this comment

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

Is there a reason we were creating our own protocol in WPUI that conforms to the Gravatar protocol?

We didn't. This was here already.

Unfortunately we can't just drop a public type from an open source library. We can't easily know where it's been used. We should always deprecate first even if we want to remove it in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately we can't just drop a public type from an open source library

Oh that's right!

One alternative, if we don't want to re-define the procotol, we can do this:

@_exported import protocol Gravatar.ImageCaching

With @_exported, WPUI will re-export ImageCaching as public, and the API won't change.
Making the changes on WPiOS not needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! This can work!

Copy link
Author

Choose a reason for hiding this comment

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

Oh nice! Didn't know about this. Perfection. I'll push this. Thanks!

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 good to me!

@pinarol - Any thoughts?

Comment on lines -176 to -180
public protocol ImageCaching: GravatarImageCaching {
func setImage(_ image: UIImage, forKey key: String)
func getImage(forKey key: String) -> UIImage?
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably existed before Gravatar SDK, and now we have the same name for the same definition of protocol.
I agree, we can drop it unless it's used somewhere else as argument independently from Gravatar, which doesn't seem to be the case 🤔

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.

@andrewdmontgomery andrewdmontgomery marked this pull request as ready for review February 26, 2024 17:45
@andrewdmontgomery
Copy link
Author

@etoledom and @pinarol

I made the change and moved the testing steps to this PR, since WPiOS won't need any changes. I'll close the WPiOS PR/branch.

@etoledom etoledom self-requested a review February 26, 2024 17:49
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.

:shipit:

@andrewdmontgomery andrewdmontgomery merged commit 3de7421 into task/gravatar-integration Feb 26, 2024
2 of 5 checks passed
@andrewdmontgomery andrewdmontgomery deleted the andrewdmontgomery/rename-ImageCache branch February 26, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants