Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Modules/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ let package = Package(
.package(url: "https://github.com/wordpress-mobile/NSURL-IDN", revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"),
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250901"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.8.1"),
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250926"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.8.1-alpha.2"),
.package(
url: "https://github.com/Automattic/color-studio",
revision: "bf141adc75e2769eb469a3e095bdc93dc30be8de"
Expand Down
1 change: 0 additions & 1 deletion Modules/Sources/WordPressCore/Extensions/Avatar.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import WordPressAPI
import WordPressAPIInternal

extension Dictionary where Key == UserAvatarSize, Value == WpResponseString {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import WordPressAPI
import WordPressAPIInternal

public struct InstalledPlugin: Equatable, Hashable, Identifiable, Sendable {
public var slug: PluginSlug
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import WordPressAPI
import WordPressAPIInternal
import WordPressAPIInternal // Required for `Sendable` conformance for multiple types

// MARK: - DataStore for full plugin deatils

Expand Down
3 changes: 1 addition & 2 deletions Modules/Sources/WordPressCore/Plugins/PluginService.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import UIKit
import WordPressAPI
@preconcurrency import WordPressAPIInternal

public actor PluginService: PluginServiceProtocol {
private let client: WordPressClient
Expand Down Expand Up @@ -103,7 +102,7 @@ public actor PluginService: PluginServiceProtocol {
return installed
}

public func fetchPluginsDirectory(category: WordPressOrgApiPluginDirectoryCategory) async throws {
public func fetchPluginsDirectory(category: PluginWpOrgDirectoryCategory) async throws {
// Hard-code the pagination parameters for now. We can suface these parameters when the app needs pagination.
let plugins = try await wpOrgClient.browsePlugins(category: category, page: 1, pageSize: 10).plugins
try await pluginDirectoryBrowserDataStore.delete(query: .category(category))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import WordPressAPI
import WordPressAPIInternal

public protocol PluginServiceProtocol: Actor {

Expand All @@ -21,7 +20,7 @@ public protocol PluginServiceProtocol: Actor {
func uninstalledPlugin(slug: PluginSlug) async throws
func installPlugin(slug: PluginWpOrgDirectorySlug) async throws -> InstalledPlugin

func fetchPluginsDirectory(category: WordPressOrgApiPluginDirectoryCategory) async throws
func fetchPluginsDirectory(category: PluginWpOrgDirectoryCategory) async throws
func pluginDirectoryUpdates(query: CategorizedPluginInformationDataStoreQuery) async -> AsyncStream<Result<[CategorizedPluginInformation], Error>>

func searchPluginsDirectory(input: String) async throws -> [PluginInformation]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import WordPressAPIInternal
import WordPressAPIInternal // Required for `UpdateCheckPluginInfo` Hashable conformance

extension UpdateCheckPluginInfo: @retroactive Identifiable {
public var id: PluginSlug { plugin }
Expand Down
7 changes: 4 additions & 3 deletions Modules/Sources/WordPressCore/Users/DisplayUser.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressAPI

public struct DisplayUser: Identifiable, Codable, Hashable, Sendable {
public let id: Int64
Expand All @@ -8,7 +9,7 @@ public struct DisplayUser: Identifiable, Codable, Hashable, Sendable {
public let lastName: String
public let displayName: String
public let profilePhotoUrl: URL?
public let role: String
public let role: UserRole

public let emailAddress: String
public let websiteUrl: String?
Expand All @@ -23,7 +24,7 @@ public struct DisplayUser: Identifiable, Codable, Hashable, Sendable {
lastName: String,
displayName: String,
profilePhotoUrl: URL?,
role: String,
role: UserRole,
emailAddress: String,
websiteUrl: String?,
biography: String?
Expand All @@ -49,7 +50,7 @@ public struct DisplayUser: Identifiable, Codable, Hashable, Sendable {
lastName: "Smith",
displayName: "John Smith",
profilePhotoUrl: URL(string: "https://gravatar.com/avatar/58fc51586c9a1f9895ac70e3ca60886e?size=256"),
role: "administrator",
role: .administrator,
emailAddress: "[email protected]",
websiteUrl: "https://example.com",
biography: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
Expand Down
39 changes: 39 additions & 0 deletions Modules/Sources/WordPressCore/Users/User+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import WordPressAPI
import WordPressAPIInternal // Required for `UserRole` Equatable conformance – it'd be nice to not need this.

public extension UserRole {
var displayString: String {
self.rawValue.capitalized
}
}

extension UserRole: @retroactive Codable {
public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()
let string: String = try container.decode(String.self)
self = .custom(string)
}

public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(self.rawValue)
}
}

extension UserRole: @retroactive Comparable {

public static func < (lhs: UserRole, rhs: UserRole) -> Bool {
let lhsIndex = Self.order.firstIndex(of: lhs) ?? Int.max
let rhsIndex = Self.order.firstIndex(of: rhs) ?? Int.max
return lhsIndex < rhsIndex
}

private static let order: [UserRole] = [
.superAdmin,
.administrator,
.editor,
.author,
.contributor,
.subscriber
]
}
4 changes: 2 additions & 2 deletions Modules/Sources/WordPressCore/Users/UserService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public actor UserService: UserServiceProtocol {
}
}

public func isCurrentUserCapableOf(_ capability: String) async -> Bool {
public func isCurrentUserCapableOf(_ capability: UserCapability) async -> Bool {
await currentUser?.capabilities.keys.contains(capability) == true
}

Expand Down Expand Up @@ -79,7 +79,7 @@ private extension DisplayUser {
return nil
}

self.init(
self = DisplayUser(
id: user.id,
handle: user.slug,
username: user.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WordPressAPI
public protocol UserServiceProtocol: Actor {
func fetchUsers() async throws

func isCurrentUserCapableOf(_ capability: String) async -> Bool
func isCurrentUserCapableOf(_ capability: UserCapability) async -> Bool

func setNewPassword(id: UserId, newPassword: String) async throws

Expand Down
7 changes: 4 additions & 3 deletions WordPress/Classes/Networking/WordPressClient.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import Combine
import WordPressAPI
import WordPressAPIInternal
import WordPressAPIInternal // Required for `WpAuthenticationProvider`
import WordPressCore
import WordPressData
import WordPressShared
Expand Down Expand Up @@ -53,6 +53,7 @@ extension WordPressClient {
}
}

// TODO: Remove this
extension PluginWpOrgDirectorySlug: @retroactive ExpressibleByStringLiteral {
public typealias StringLiteralType = String

Expand Down Expand Up @@ -98,7 +99,7 @@ private final class AutoUpdateAuthenticationProvider: @unchecked Sendable, WpDyn
return authentication
}

func auth() -> WordPressAPIInternal.WpAuthentication {
func auth() -> WpAuthentication {
lock.lock()
defer {
lock.unlock()
Expand Down Expand Up @@ -133,7 +134,7 @@ private class AppNotifier: @unchecked Sendable, WpAppNotifier {
self.coreDataStack = coreDataStack
}

func requestedWithInvalidAuthentication() async {
func requestedWithInvalidAuthentication(requestUrl: String) async {
let blogId = site.blogId(in: coreDataStack)
NotificationCenter.default.post(name: WordPressClient.requestedWithInvalidAuthenticationNotification, object: blogId)
}
Expand Down
3 changes: 1 addition & 2 deletions WordPress/Classes/Plugins/Views/AddNewPluginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Foundation
import SwiftUI
import WordPressCore
import WordPressAPI
import WordPressAPIInternal

struct AddNewPluginView: View {
@Environment(\.dismiss) var dismiss
Expand Down Expand Up @@ -214,7 +213,7 @@ private class AddNewPluginViewModel: ObservableObject {
case popular
case recommended

var wpOrgCategory: WordPressOrgApiPluginDirectoryCategory {
var wpOrgCategory: PluginWpOrgDirectoryCategory {
// TODO: Update the returned values to be the correct onces after updating the wordpress-rs library
switch self {
case .featured:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import SwiftUI
import AsyncImageKit
import WordPressUI
import WordPressAPI
import WordPressAPIInternal
import WordPressCore

struct InstalledPluginsListView: View {
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/Plugins/Views/PluginDetailsView.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Foundation
import SwiftUI
import AsyncImageKit
import WordPressAPI
import WordPressAPIInternal // Required for `Screenshot`, `Ratings`
import WordPressCore
import WordPressAPIInternal

struct PluginDetailsView: View {
private struct BasicPluginInfo {
Expand Down
1 change: 0 additions & 1 deletion WordPress/Classes/Plugins/Views/PluginIconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Foundation
import SwiftUI
import AsyncImageKit
import WordPressAPI
import WordPressAPIInternal
import WordPressCore

struct PluginIconView: View {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import WordPressCore
import WordPressAPI
import WordPressAPIInternal
import WordPressAPIInternal // Required for `WpApiParamCommentsOrderBy`
import WordPressKit
import WordPressShared
import WordPressData
Expand Down Expand Up @@ -149,7 +149,7 @@ private extension RemoteComment {
self.postID = NSNumber(value: comment.post)

self.status = comment.status.commentStatusType?.description
self.type = comment.commentType.type
self.type = comment.commentType.rawValue

if let ext = try? comment.additionalFields.parseWpcomCommentsExtension() {
self.postTitle = ext.post?.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Combine
import WordPressCore
import WordPressShared
import WordPressAPI
import WordPressAPIInternal
import WordPressKit

/// A `MediaServiceRemote` implementation that uses the WordPress core REST API (`/wp-json/wp/v2/media`).
Expand Down
Loading