From 74fdffc789fcb8191bf5042ce4ae3c734b36941a Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 16 Feb 2024 15:50:49 +0300 Subject: [PATCH] Use GravatarURL in more places (#22624) Co-authored-by: Pinar Olguc --- .../ViewRelated/Comments/CommentContentTableViewCell.swift | 3 ++- .../Notifications/Views/NoteBlockCommentTableViewCell.swift | 3 ++- .../Notifications/Views/NoteBlockHeaderTableViewCell.swift | 3 ++- .../Notifications/Views/NoteBlockUserTableViewCell.swift | 3 ++- WordPress/Classes/ViewRelated/People/PeopleCell.swift | 3 ++- .../Classes/ViewRelated/People/PersonViewController.swift | 3 ++- .../Post/Revisions/Views/Cell/RevisionsTableViewCell.swift | 3 ++- .../Sources/Views/NotificationContentView.swift | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift index 481190555ecf..0dc0d0ceca3b 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift @@ -1,5 +1,6 @@ import UIKit import WordPressUI +import Gravatar class CommentContentTableViewCell: UITableViewCell, NibReusable { @@ -357,7 +358,7 @@ private extension CommentContentTableViewCell { /// If the URL does not contain any image, the default placeholder image will be displayed. /// - Parameter url: The URL containing the image. func configureImage(with url: URL?) { - if let someURL = url, let gravatar = Gravatar(someURL) { + if let someURL = url, let gravatar = GravatarURL(someURL) { avatarImageView.downloadGravatar(gravatar, placeholder: Style.placeholderImage, animate: true) return } diff --git a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockCommentTableViewCell.swift b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockCommentTableViewCell.swift index d2840dff708b..8f1201c14304 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockCommentTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockCommentTableViewCell.swift @@ -1,6 +1,7 @@ import Foundation import WordPressShared.WPStyleGuide import WordPressUI +import Gravatar // MARK: - NoteBlockCommentTableViewCell Renders a Comment Block Onscreen // @@ -99,7 +100,7 @@ class NoteBlockCommentTableViewCell: NoteBlockTextTableViewCell { // MARK: - Public Methods @objc func downloadGravatarWithURL(_ url: URL?) { - let gravatar = url.flatMap { Gravatar($0) } + let gravatar = url.flatMap { GravatarURL($0) } gravatarImageView.downloadGravatar(gravatar, placeholder: placeholderImage, animate: true) } diff --git a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockHeaderTableViewCell.swift b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockHeaderTableViewCell.swift index 9e2c7c0d18ed..12ceca15d5e4 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockHeaderTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockHeaderTableViewCell.swift @@ -1,6 +1,7 @@ import Foundation import WordPressShared.WPStyleGuide import WordPressUI +import Gravatar // MARK: - NoteBlockHeaderTableViewCell // @@ -67,7 +68,7 @@ class NoteBlockHeaderTableViewCell: NoteBlockTableViewCell { return } - if let gravatar = Gravatar(url) { + if let gravatar = GravatarURL(url) { authorAvatarImageView.downloadGravatar(gravatar, placeholder: .gravatarPlaceholderImage, animate: true) } else { authorAvatarImageView.downloadSiteIcon(at: url.absoluteString) diff --git a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockUserTableViewCell.swift b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockUserTableViewCell.swift index e561f225ddd4..517af85ef373 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockUserTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockUserTableViewCell.swift @@ -1,6 +1,7 @@ import Foundation import WordPressShared import WordPressUI +import Gravatar class NoteBlockUserTableViewCell: NoteBlockTableViewCell { typealias EventHandler = (() -> Void) @@ -54,7 +55,7 @@ class NoteBlockUserTableViewCell: NoteBlockTableViewCell { return } - let gravatar = url.flatMap { Gravatar($0) } + let gravatar = url.flatMap { GravatarURL($0) } gravatarImageView.downloadGravatar(gravatar, placeholder: .gravatarPlaceholderImage, animate: true) gravatarURL = url diff --git a/WordPress/Classes/ViewRelated/People/PeopleCell.swift b/WordPress/Classes/ViewRelated/People/PeopleCell.swift index e4d00163b137..d80078b6c156 100644 --- a/WordPress/Classes/ViewRelated/People/PeopleCell.swift +++ b/WordPress/Classes/ViewRelated/People/PeopleCell.swift @@ -1,6 +1,7 @@ import UIKit import WordPressShared import WordPressUI +import Gravatar class PeopleCell: WPTableViewCell { @IBOutlet private weak var avatarImageView: CircularImageView! @@ -36,7 +37,7 @@ class PeopleCell: WPTableViewCell { } @objc func setAvatarURL(_ avatarURL: URL?) { - let gravatar = avatarURL.flatMap { Gravatar($0) } + let gravatar = avatarURL.flatMap { GravatarURL($0) } let placeholder = UIImage(named: "gravatar")! avatarImageView.downloadGravatar(gravatar, placeholder: placeholder, animate: false) } diff --git a/WordPress/Classes/ViewRelated/People/PersonViewController.swift b/WordPress/Classes/ViewRelated/People/PersonViewController.swift index 59d56700dabf..e452688b1752 100644 --- a/WordPress/Classes/ViewRelated/People/PersonViewController.swift +++ b/WordPress/Classes/ViewRelated/People/PersonViewController.swift @@ -3,6 +3,7 @@ import UIKit import CocoaLumberjack import WordPressShared import WordPressUI +import Gravatar /// Displays a Blog's User Details /// @@ -507,7 +508,7 @@ private extension PersonViewController { } func refreshGravatarImage(in imageView: UIImageView) { - let gravatar = person.avatarURL.flatMap { Gravatar($0) } + let gravatar = person.avatarURL.flatMap { GravatarURL($0) } let placeholder = UIImage(named: "gravatar")! imageView.downloadGravatar(gravatar, placeholder: placeholder, animate: false) } diff --git a/WordPress/Classes/ViewRelated/Post/Revisions/Views/Cell/RevisionsTableViewCell.swift b/WordPress/Classes/ViewRelated/Post/Revisions/Views/Cell/RevisionsTableViewCell.swift index e414a6417fb7..01f9198c6912 100644 --- a/WordPress/Classes/ViewRelated/Post/Revisions/Views/Cell/RevisionsTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Post/Revisions/Views/Cell/RevisionsTableViewCell.swift @@ -1,5 +1,6 @@ import Gridicons import WordPressUI +import Gravatar class RevisionsTableViewCell: UITableViewCell { static let reuseIdentifier = "RevisionsTableViewCellIdentifier" @@ -43,7 +44,7 @@ class RevisionsTableViewCell: UITableViewCell { if let avatarURL = avatarURL, let placeholder = UIImage(named: "gravatar") { let url = URL(string: avatarURL) - avatarImageView.downloadGravatar(url.flatMap { Gravatar($0) }, + avatarImageView.downloadGravatar(url.flatMap { GravatarURL($0) }, placeholder: placeholder, animate: false) } diff --git a/WordPress/WordPressNotificationContentExtension/Sources/Views/NotificationContentView.swift b/WordPress/WordPressNotificationContentExtension/Sources/Views/NotificationContentView.swift index 11586b65d884..949a36ce0980 100644 --- a/WordPress/WordPressNotificationContentExtension/Sources/Views/NotificationContentView.swift +++ b/WordPress/WordPressNotificationContentExtension/Sources/Views/NotificationContentView.swift @@ -2,6 +2,7 @@ import UIKit import WordPressShared import WordPressUI +import Gravatar // MARK: - NotificationContentView @@ -186,7 +187,7 @@ extension NotificationContentView { func downloadGravatar() { guard let specifiedGravatar = viewModel.gravatarURLString, let validURL = URL(string: specifiedGravatar), - let gravatar = Gravatar(validURL) else { + let gravatar = GravatarURL(validURL) else { return }