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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
1 change: 1 addition & 0 deletions ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import WebKit

/// A type that represents JavaScript messages send from and to the web view.
@MainActor
struct EditorJSMessage {
let type: MessageType
let body: Any?
Expand Down
12 changes: 5 additions & 7 deletions ios/Sources/GutenbergKit/Sources/EditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -573,20 +573,18 @@ private final class GutenbergEditorController: NSObject, WKNavigationDelegate, W
NSLog("didFailProvisionalNavigation: \(error)")
}

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
guard let url = navigationAction.request.url else {
decisionHandler(.allow)
return
return .allow
}

if navigationAction.navigationType == .linkActivated {
// Open the request in OS browser
UIApplication.shared.open(url)
decisionHandler(.cancel)
return
await UIApplication.shared.open(url)
return .cancel
}

decisionHandler(.allow)
return .allow
}

// MARK: - WKScriptMessageHandler
Expand Down
2 changes: 1 addition & 1 deletion ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct MediaInfo: Codable {
public struct MediaInfo: Sendable, Codable {
public let id: Int32?
public let url: String?
public let type: String?
Expand Down
5 changes: 0 additions & 5 deletions ios/Sources/GutenbergKit/Sources/Service/EditorService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public actor EditorService {
let startTime = CFAbsoluteTimeGetCurrent()
log(.info, "Starting editor resources refresh")

guard let baseURL = URL(string: configuration.siteApiRoot) else {
log(.error, "Invalid siteApiRoot URL: \(configuration.siteApiRoot)")
return
}

// Fetch settings and manifest in parallel
async let settingsFuture = Result {
try await fetchEditorSettings(configuration: configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,14 @@ class BlockInserterViewModel: ObservableObject {
let task = Task<[MediaInfo], Never> { @MainActor in
var results: [MediaInfo] = []
var anyError: Error?
await withTaskGroup(of: Void.self) { group in

do {
for item in items {
group.addTask {
do {
let item = try await self.fileManager.import(item)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Multiple operations like this are competing for many of the same resources (network and Disk IO) so I'm not sure parallelizing them here is much of a win.

If you don't love this I can try something new, this was just a quick fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like I generated this code I have no memory of it. I do not like unbounded parallelization for sure.

For file operations, it's largely irrelevant. I'm not sure if there may be scenarios where it needs to trigger download of the original data from the cloud. In that case, you probably want to trigger them all at once and Apple will presumably take care of the networking and limiting the requests.

results.append(item)
} catch {
anyError = error
}
}
let item = try await self.fileManager.import(item)
results.append(item)
}
} catch {
anyError = error
}

guard !Task.isCancelled else {
Expand Down