Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/18536-stats-percentage-sign-should-be-l…
Browse files Browse the repository at this point in the history
…ocalized-in-stats-screen
  • Loading branch information
staskus committed Apr 3, 2024
2 parents ba5c2de + c2d4a35 commit 1cbd4c8
Show file tree
Hide file tree
Showing 36 changed files with 346 additions and 108 deletions.
14 changes: 10 additions & 4 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ def aztec
end

def wordpress_ui
pod 'WordPressUI', '~> 1.15'
pod 'WordPressUI', '~> 1.16'
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', tag: ''
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', branch: ''
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', commit: ''
# pod 'WordPressUI', path: '../WordPressUI-iOS'
end

def gravatar
# pod 'Gravatar', path: '../Gravatar-SDK-iOS'
pod 'Gravatar', '1.0.0'
end

def wordpress_kit
# pod 'WordPressKit', '~> 15.0'
pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: '6a3b5c873069ec9c3efc336f5dd22dddd582a246'
pod 'WordPressKit', '~> 16.0.0'
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', branch: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', tag: ''
# pod 'WordPressKit', path: '../WordPressKit-iOS'
Expand Down Expand Up @@ -128,6 +133,7 @@ abstract_target 'Apps' do
wordpress_kit
wordpress_shared
kanvas
gravatar

# Production

Expand All @@ -139,7 +145,7 @@ abstract_target 'Apps' do

pod 'NSURL+IDN', '~> 0.4'

pod 'WordPressAuthenticator', '~> 9.0', '>= 9.0.2'
pod 'WordPressAuthenticator', '~> 9.0', '>= 9.0.6'
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', commit: ''
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', branch: ''
# pod 'WordPressAuthenticator', path: '../WordPressAuthenticator-iOS'
Expand Down
33 changes: 16 additions & 17 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PODS:
- Down (0.6.6)
- FSInteractiveMap (0.1.0)
- Gifu (3.3.1)
- Gravatar (1.0.0)
- Gridicons (1.2.0)
- Gutenberg (1.116.0)
- JTAppleCalendar (8.0.5)
Expand Down Expand Up @@ -63,20 +64,20 @@ PODS:
- WordPress-Aztec-iOS (1.19.11)
- WordPress-Editor-iOS (1.19.11):
- WordPress-Aztec-iOS (= 1.19.11)
- WordPressAuthenticator (9.0.4):
- WordPressAuthenticator (9.0.6):
- Gridicons (~> 1.0)
- "NSURL+IDN (= 0.4)"
- SVProgressHUD (~> 2.2.5)
- WordPressKit (~> 15.0)
- WordPressKit (~> 16.0)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)
- WordPressKit (15.0.0):
- WordPressKit (16.0.0):
- NSObject-SafeExpectations (~> 0.0.4)
- UIDeviceIdentifier (~> 2.0)
- WordPressShared (~> 2.0-beta)
- wpxmlrpc (~> 0.10)
- WordPressShared (2.3.1)
- WordPressUI (1.15.1)
- WordPressUI (1.16.0)
- wpxmlrpc (0.10.0)
- ZendeskCommonUISDK (6.1.4)
- ZendeskCoreSDK (2.5.1)
Expand Down Expand Up @@ -104,6 +105,7 @@ DEPENDENCIES:
- Down (~> 0.6.6)
- FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`)
- Gifu (= 3.3.1)
- Gravatar (= 1.0.0)
- Gridicons (~> 1.2)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.116.0.podspec`)
- JTAppleCalendar (~> 8.0.5)
Expand All @@ -118,10 +120,10 @@ DEPENDENCIES:
- SVProgressHUD (= 2.2.5)
- SwiftLint (= 0.54.0)
- WordPress-Editor-iOS (~> 1.19.11)
- WordPressAuthenticator (>= 9.0.2, ~> 9.0)
- WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `6a3b5c873069ec9c3efc336f5dd22dddd582a246`)
- WordPressAuthenticator (>= 9.0.6, ~> 9.0)
- WordPressKit (~> 16.0.0)
- WordPressShared (>= 2.3.1, ~> 2.3)
- WordPressUI (~> 1.15)
- WordPressUI (~> 1.16)
- ZendeskSupportSDK (= 5.3.0)
- ZIPFoundation (~> 0.9.8)

Expand All @@ -140,6 +142,7 @@ SPEC REPOS:
- CropViewController
- Down
- Gifu
- Gravatar
- Gridicons
- JTAppleCalendar
- Kanvas
Expand All @@ -156,6 +159,7 @@ SPEC REPOS:
- SVProgressHUD
- SwiftLint
- UIDeviceIdentifier
- WordPressKit
- WordPressShared
- WordPressUI
- wpxmlrpc
Expand All @@ -174,17 +178,11 @@ EXTERNAL SOURCES:
:tag: 0.2.0
Gutenberg:
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.116.0.podspec
WordPressKit:
:commit: 6a3b5c873069ec9c3efc336f5dd22dddd582a246
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

CHECKOUT OPTIONS:
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
WordPressKit:
:commit: 6a3b5c873069ec9c3efc336f5dd22dddd582a246
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

SPEC CHECKSUMS:
Alamofire: 02b772c9910e8eba1a079227c32fbd9e46c90a24
Expand All @@ -197,6 +195,7 @@ SPEC CHECKSUMS:
Down: 71bf4af3c04fa093e65dffa25c4b64fa61287373
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gravatar: bdd3950c5128304b51a9e655e4145334f23201d1
Gridicons: 4455b9f366960121430e45997e32112ae49ffe1d
Gutenberg: fda9c1f9d8d5ec0b565d0efb32757a39b046f538
JTAppleCalendar: 16c6501b22cb27520372c28b0a2e0b12c8d0cd73
Expand All @@ -216,10 +215,10 @@ SPEC CHECKSUMS:
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
WordPress-Aztec-iOS: 3732c6d865a5c9f35788377bdeda8a80ea10d0a1
WordPress-Editor-iOS: 453345420ced3d3ef20f0051b3df46ff10281e0c
WordPressAuthenticator: 47ac66428c0a712ced8eb0ab481f64e2f4e80f47
WordPressKit: d4db2fa5861380bd6b71d5574f2bc63cdeee47ba
WordPressAuthenticator: 6be121346d4303dd32904a57f6d0e68eaa825152
WordPressKit: f6dc2acce37a526ddb59e02388b3d59da50918ed
WordPressShared: 04c6d51441bb8fa29651075b3a5536c90ae89c76
WordPressUI: 700e3ec5a9f77b6920c8104c338c85788036ab3c
WordPressUI: ec5ebcf7e63e797ba51d07513e340c1b14cf45a4
wpxmlrpc: 68db063041e85d186db21f674adf08d9c70627fd
ZendeskCommonUISDK: ba160fe413b491af9e7bfcb9808afcd494dc83a5
ZendeskCoreSDK: 19a18e5ef2edcb18f4dbc0ea0d12bd31f515712a
Expand All @@ -230,6 +229,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: fa9ae5af13b7cf168245f24d1c672a4fb972e37f

PODFILE CHECKSUM: b7cab86f4b24a5c0fb443ceb9cece8b48ffad2f6
PODFILE CHECKSUM: 1b7cffff7fff31174523088dc11490db0a1769eb

COCOAPODS: 1.15.2
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
24.7
-----


24.6
-----
* [**] Block editor: Highlight text fixes [https://github.com/WordPress/gutenberg/pull/57650]
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/Models/ManagedPerson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import CoreData
import WordPressKit
import WordPressUI
import Gravatar

public typealias Person = RemotePerson

Expand All @@ -10,7 +11,7 @@ public typealias Person = RemotePerson
class ManagedPerson: NSManagedObject {

func updateWith<T: Person>(_ person: T) {
let canonicalAvatarURL = person.avatarURL.flatMap { Gravatar($0)?.canonicalURL }
let canonicalAvatarURL = person.avatarURL.flatMap { AvatarURL(url: $0)?.canonicalURL }

avatarURL = canonicalAvatarURL?.absoluteString
displayName = person.displayName
Expand Down
42 changes: 25 additions & 17 deletions WordPress/Classes/Services/GravatarService.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import Foundation
import CocoaLumberjack
import WordPressKit
import Gravatar

@objc public enum GravatarServiceError: Int, Error {
case invalidAccountInfo
}

public protocol GravatarImageUploader {
@discardableResult
func upload(_ image: UIImage, email: Email, accessToken: String) async throws -> URLResponse
}

extension AvatarService: GravatarImageUploader { }

/// This Service exposes all of the valid operations we can execute, to interact with the Gravatar Service.
///
open class GravatarService {
public class GravatarService {

let imageUploader: GravatarImageUploader

init(imageUploader: GravatarImageUploader? = nil) {
self.imageUploader = imageUploader ?? AvatarService()
}

/// This method fetches the Gravatar profile for the specified email address.
///
Expand All @@ -17,7 +31,7 @@ open class GravatarService {
/// - completion: A completion block.
///
open func fetchProfile(email: String, onCompletion: @escaping ((_ profile: GravatarProfile?) -> Void)) {
let remote = gravatarServiceRemote()
let remote = GravatarServiceRemote()
remote.fetchProfile(email, success: { remoteProfile in
var profile = GravatarProfile()
profile.profileID = remoteProfile.profileID
Expand All @@ -43,31 +57,25 @@ open class GravatarService {
/// - account: The WPAccount instance for which to upload a new image.
/// - completion: An optional closure to be executed on completion.
///
open func uploadImage(_ image: UIImage, forAccount account: WPAccount, completion: ((_ error: NSError?) -> ())? = nil) {
open func uploadImage(_ image: UIImage, forAccount account: WPAccount, completion: ((_ error: Error?) -> ())? = nil) {
guard
let accountToken = account.authToken, !accountToken.isEmpty,
let accountEmail = account.email, !accountEmail.isEmpty else {
completion?(GravatarServiceError.invalidAccountInfo as NSError)
completion?(GravatarServiceError.invalidAccountInfo)
return
}

let email = accountEmail.trimmingCharacters(in: CharacterSet.whitespaces).lowercased()

let remote = gravatarServiceRemote()
remote.uploadImage(image, accountEmail: email, accountToken: accountToken) { (error) in
if let theError = error {
DDLogError("GravatarService.uploadImage Error: \(theError)")
} else {
Task {
do {
try await imageUploader.upload(image, email: Email(email), accessToken: accountToken)
DDLogInfo("GravatarService.uploadImage Success!")
completion?(nil)
} catch {
DDLogError("GravatarService.uploadImage Error: \(error)")
completion?(error)
}

completion?(error)
}
}

/// Overridden by tests for mocking.
///
func gravatarServiceRemote() -> GravatarServiceRemote {
return GravatarServiceRemote()
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Foundation
import WordPressUI
import Gravatar

extension ImageDownloader {

nonisolated func downloadGravatarImage(with email: String, completion: @escaping (UIImage?) -> Void) {

guard let url = Gravatar.gravatarUrl(for: email) else {
guard let url = AvatarURL.url(for: email) else {
completion(nil)
return
}
Expand Down
5 changes: 4 additions & 1 deletion WordPress/Classes/Utility/Media/MemoryCache.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import AlamofireImage
import WordPressUI
import protocol Gravatar.ImageCaching

protocol MemoryCacheProtocol: AnyObject {
subscript(key: String) -> UIImage? { get set }
Expand Down Expand Up @@ -88,7 +89,9 @@ extension MemoryCache {
}
}

private struct WordpressUICacheAdapter: WordPressUI.ImageCaching {
public protocol GravatarImageCaching: WordPressUI.ImageCaching, ImageCaching { }

private struct WordpressUICacheAdapter: GravatarImageCaching {
let cache: MemoryCache

func setImage(_ image: UIImage, forKey key: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fileprivate extension UIBarButtonItem {
gravatarImageView.contentMode = .scaleAspectFill

if let email = email {
gravatarImageView.downloadGravatarWithEmail(email, placeholderImage: GravatarConfiguration.fallBackImage)
gravatarImageView.downloadGravatar(for: email, placeholderImage: GravatarConfiguration.fallBackImage)
} else {
gravatarImageView.image = GravatarConfiguration.fallBackImage
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import WordPressUI
import Gravatar

extension BlogDetailsViewController {

Expand Down Expand Up @@ -27,7 +28,7 @@ extension BlogDetailsViewController {
guard let userInfo = notification.userInfo,
let email = userInfo["email"] as? String,
let image = userInfo["image"] as? UIImage,
let url = Gravatar.gravatarUrl(for: email),
let url = AvatarURL.url(for: email),
let gravatarIcon = image.gravatarIcon(size: Metrics.iconSize) else {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import WordPressUI
import Gravatar

struct NoSitesViewModel {

Expand All @@ -16,7 +17,7 @@ struct NoSitesViewModel {
self.appUIType = appUIType
self.displayName = account?.displayName ?? "-"
if let email = account?.email {
self.gravatarURL = Gravatar.gravatarUrl(for: email)
self.gravatarURL = AvatarURL.url(for: email)
} else {
self.gravatarURL = nil
}
Expand Down
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 = AvatarURL(url: someURL) {
avatarImageView.downloadGravatar(gravatar, placeholder: Style.placeholderImage, animate: true)
return
}
Expand All @@ -374,7 +375,7 @@ private extension CommentContentTableViewCell {
return
}

avatarImageView.downloadGravatarWithEmail(someEmail, placeholderImage: Style.placeholderImage)
avatarImageView.downloadGravatar(for: someEmail, placeholderImage: Style.placeholderImage)
}

func updateContainerLeadingConstraint() {
Expand Down
Loading

0 comments on commit 1cbd4c8

Please sign in to comment.