Skip to content

Commit

Permalink
Address some warnings in the Gutenberg iOS code used by the React Nat…
Browse files Browse the repository at this point in the history
…ive layer (#49739)

* Address "Empty collection literal requires an explicit type" warning

* Remove redundant `public` modifier used in `public extension`

* Address warning about unused result of `wait(timeout:)` call

* Replace `class` constraints with modern `AnyObject`

See compiler warning:

> Using 'class' keyword to define a class-constrained protocol is deprecated;
> use 'AnyObject' instead

* Order `SourceFile.swift` resources alphabetically

This makes it easier to scan them.
  • Loading branch information
mokagio authored Apr 13, 2023
1 parent 9daffed commit 595d774
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react-native-bridge/ios/Gutenberg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ extension Gutenberg: RCTBridgeDelegate {
}
let monitorQueue = DispatchQueue(label: "org.wordpress.network-path-monitor")
monitor.start(queue: monitorQueue)
semaphore.wait(timeout: .distantFuture)
_ = semaphore.wait(timeout: .distantFuture)
monitor.cancel()
if isOnCellularNetwork {
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Aztec

public protocol GutenbergBridgeDataSource: class {
public protocol GutenbergBridgeDataSource: AnyObject {
/// Asks the data source for the initial html content to be presented by the editor.
/// Return `nil` to show the example content.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension RCTLogLevel {
}
}

public protocol GutenbergBridgeDelegate: class {
public protocol GutenbergBridgeDelegate: AnyObject {
/// Tells the delegate that Gutenberg had returned the requested HTML content.
/// You can request HTML content by calling `requestHTML()` on a Gutenberg bridge instance.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import WebKit

public protocol GutenbergWebDelegate: class {
public protocol GutenbergWebDelegate: AnyObject {
func webController(controller: GutenbergWebSingleBlockViewController, didPressSave block: Block)
func webControllerDidPressClose(controller: GutenbergWebSingleBlockViewController)
func webController(controller: GutenbergWebSingleBlockViewController, didLog log: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
// MARK: - RCTBridgeModule delegate

public extension Gutenberg {
public enum ActionButtonType: String {
enum ActionButtonType: String {
case missingBlockAlertActionButton = "missing_block_alert_action_button"
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/react-native-bridge/ios/SourceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension SourceFile {

public func jsScript(with argument: String? = nil) throws -> WKUserScript {
let content = try getContent()
let formatted = String(format: content, argument ?? [])
let formatted = String(format: content, argument ?? "")

switch self.type {
case .css:
Expand All @@ -48,14 +48,14 @@ extension SourceFile {
}

extension SourceFile {
static let retrieveHtml = SourceFile(name: "content-functions", type: .js)
static let editorBehavior = SourceFile(name: "editor-behavior-overrides", type: .js)
static let editorStyle = SourceFile(name: "editor-style-overrides", type: .css)
static let wpBarsStyle = SourceFile(name: "wp-bar-override", type: .css)
static let gutenbergObserver = SourceFile(name: "gutenberg-observer", type: .js)
static let injectCss = SourceFile(name: "inject-css", type: .js)
static let retrieveHtml = SourceFile(name: "content-functions", type: .js)
static let insertBlock = SourceFile(name: "insert-block", type: .js)
static let localStorage = SourceFile(name: "local-storage-overrides", type: .json)
static let preventAutosaves = SourceFile(name: "prevent-autosaves", type: .js)
static let gutenbergObserver = SourceFile(name: "gutenberg-observer", type: .js)
static let supportedBlocks = SourceFile(name: "supported-blocks", type: .json)
static let editorBehavior = SourceFile(name: "editor-behavior-overrides", type: .js)
static let wpBarsStyle = SourceFile(name: "wp-bar-override", type: .css)
}

1 comment on commit 595d774

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 595d774.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4684959383
📝 Reported issues:

Please sign in to comment.