Skip to content

Commit

Permalink
Use GravatarURL in more places (#22624)
Browse files Browse the repository at this point in the history
Co-authored-by: Pinar Olguc <[email protected]>
  • Loading branch information
pinarol and pinarol authored Feb 16, 2024
1 parent a061bb7 commit 74fdffc
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import WordPressUI
import Gravatar

class CommentContentTableViewCell: UITableViewCell, NibReusable {

Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import WordPressShared.WPStyleGuide
import WordPressUI
import Gravatar

// MARK: - NoteBlockCommentTableViewCell Renders a Comment Block Onscreen
//
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import WordPressShared.WPStyleGuide
import WordPressUI
import Gravatar

// MARK: - NoteBlockHeaderTableViewCell
//
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import WordPressShared
import WordPressUI
import Gravatar

class NoteBlockUserTableViewCell: NoteBlockTableViewCell {
typealias EventHandler = (() -> Void)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/ViewRelated/People/PeopleCell.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit
import WordPressShared
import WordPressUI
import Gravatar

class PeopleCell: WPTableViewCell {
@IBOutlet private weak var avatarImageView: CircularImageView!
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import UIKit
import CocoaLumberjack
import WordPressShared
import WordPressUI
import Gravatar

/// Displays a Blog's User Details
///
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Gridicons
import WordPressUI
import Gravatar

class RevisionsTableViewCell: UITableViewCell {
static let reuseIdentifier = "RevisionsTableViewCellIdentifier"
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UIKit

import WordPressShared
import WordPressUI
import Gravatar

// MARK: - NotificationContentView

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 74fdffc

Please sign in to comment.