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
5 changes: 2 additions & 3 deletions Modules/Package.resolved

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

2 changes: 1 addition & 1 deletion Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let package = Package(
.package(url: "https://github.com/wordpress-mobile/wpxmlrpc", from: "0.9.0"),
.package(url: "https://github.com/wordpress-mobile/NSURL-IDN", revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"),
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.13.2"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "c60333ebf4bd37eafc8981cfc8387b71bdfa5dcc"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@crazytonyli before merging, we should publish and integrate a GBK prerelease rather than a Git hash, if possible. This currently points to a commit in an unmerged GBK PR.

// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20260210"),
.package(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct EditorConfigurationTests {
.with(dotComID: 12345)
.build()

let config = EditorConfiguration(blog: blog)
let config = EditorConfiguration(blog: blog, postType: .post)

#expect(config.siteApiRoot == URL(string: "https://public-api.wordpress.com/")!, "Should use WP.com API root")
#expect(config.authHeader == "Bearer simple-bearer-token", "Should use Bearer authentication from account")
Expand All @@ -46,7 +46,7 @@ struct EditorConfigurationTests {
.with(url: "https://atomic.com")
.build()

let config = EditorConfiguration(blog: blog)
let config = EditorConfiguration(blog: blog, postType: .post)

#expect(config.siteApiRoot == URL(string: "https://public-api.wordpress.com/")!, "Should use WP.com API root")
#expect(config.authHeader == "Bearer atomic-bearer-token", "Should use Bearer authentication")
Expand All @@ -65,7 +65,7 @@ struct EditorConfigurationTests {
.withApplicationPassword("test-app-password-1234", using: keychain)
.build()

let config = EditorConfiguration(blog: blog, keychain: keychain)
let config = EditorConfiguration(blog: blog, postType: .post, keychain: keychain)
let base64Credentials = "YXRvbWljdXNlcjp0ZXN0LWFwcC1wYXNzd29yZC0xMjM0" // Base64 encoding of "atomicuser:test-app-password-1234"

#expect(config.siteApiRoot == URL(string: "https://67890.example.com/wp-json/")!, "Should use self-hosted API URL")
Expand All @@ -86,7 +86,7 @@ struct EditorConfigurationTests {
.with(restApiRootURL: "https://self-hosted.org/wp-json/")
.build()

let config = EditorConfiguration(blog: blog, keychain: keychain)
let config = EditorConfiguration(blog: blog, postType: .post, keychain: keychain)
let base64Credentials = "c2VsZmhvc3RlZHVzZXI6dGVzdC1hcHAtcGFzc3dvcmQtMTIzNA==" // Base64 encoding of "selfhosteduser:test-app-password-1234"

#expect(config.siteApiRoot == URL(string: "https://self-hosted.org/wp-json/")!, "Should use self-hosted API URL")
Expand All @@ -106,7 +106,7 @@ struct EditorConfigurationTests {
.with(url: "https://self-hosted.org")
.build()

let config = EditorConfiguration(blog: blog, keychain: keychain)
let config = EditorConfiguration(blog: blog, postType: .post, keychain: keychain)

#expect(config.siteApiRoot == URL(string: "https://public-api.wordpress.com/"), "Should use WP.com API root")
#expect(config.authHeader == "Bearer self-hosted-bearer-token", "Should use Bearer authentication")
Expand All @@ -127,7 +127,7 @@ struct EditorConfigurationTests {
.with(restApiRootURL: "https://self-hosted.org/wp-json/")
.build()

let config = EditorConfiguration(blog: blog, keychain: keychain)
let config = EditorConfiguration(blog: blog, postType: .post, keychain: keychain)
let base64Credentials = "c2VsZmhvc3RlZHVzZXI6dGVzdC1hcHAtcGFzc3dvcmQtMTIzNA==" // Base64 encoding of "selfhosteduser:test-app-password-1234"

#expect(config.siteApiRoot == URL(string: "https://self-hosted.org/wp-json/"), "Should use self-hosted API URL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ protocol OverridableFlag: CustomStringConvertible {
/// Used to override values for feature flags at runtime in debug builds
///
struct FeatureFlagOverrideStore {
static let didChangeNotification = Notification.Name("FeatureFlagOverrideStore.didChange")
static let notificationFeatureFlagKey = "featureFlag"

private let store: KeyValueDatabase

init(store: KeyValueDatabase = UserDefaults.standard) {
Expand All @@ -36,10 +39,13 @@ struct FeatureFlagOverrideStore {
if value != featureFlag.originalValue {
store.set(value, forKey: key)
}

postDidChangeNotification(for: featureFlag)
}

func removeOverride(for featureFlag: OverridableFlag) {
store.removeObject(forKey: featureFlag.key)
postDidChangeNotification(for: featureFlag)
}

/// - returns: The overridden value for the specified feature flag, if one exists.
Expand All @@ -58,6 +64,14 @@ struct FeatureFlagOverrideStore {
return nil
}
}

private func postDidChangeNotification(for featureFlag: OverridableFlag) {
NotificationCenter.default.post(
name: Self.didChangeNotification,
object: nil,
userInfo: [Self.notificationFeatureFlagKey: featureFlag]
)
}
}

enum FeatureFlagError: Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WordPressShared
import Support

extension EditorConfiguration {
init(blog: Blog, postType: String = "post", keychain: KeychainAccessible = KeychainUtils()) {
init(blog: Blog, postType: PostTypeDetails, keychain: KeychainAccessible = KeychainUtils()) {
let selfHostedApiUrl = blog.restApiRootURL ?? blog.url(withPath: "wp-json/")
let applicationPassword = try? blog.getApplicationToken(using: keychain)
let shouldUseWPComRestApi = applicationPassword == nil && blog.isAccessibleThroughWPCom()
Expand Down
Loading