Skip to content
Draft
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 @@ -54,7 +54,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.10.1"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "4fe41400aeb43350e7116954694c0a6072a8f26b"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20251101"),
.package(
Expand Down
50 changes: 0 additions & 50 deletions WordPress/Classes/Services/BlockEditorCache.swift

This file was deleted.

58 changes: 0 additions & 58 deletions WordPress/Classes/Services/RawBlockEditorSettingsService.swift

This file was deleted.

3 changes: 0 additions & 3 deletions WordPress/Classes/Utility/AccountHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ import WordPressData
// This is best-effort for now – eventually all of this should be async
Task {
do {
// Delete all cached block editor settings
try await BlockEditorCache.shared.deleteAll()

// Delete everything in the disk cache
try await DiskCache().removeAll()
} catch {
Expand Down
10 changes: 10 additions & 0 deletions WordPress/Classes/Utility/Editor/EditorConfiguration+Blog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ extension EditorConfiguration {
if let siteApiRoot {
builder = builder.setSiteApiRoot(siteApiRoot)

if var editorSettingsEndpoint = URL(string: siteApiRoot) {
editorSettingsEndpoint.appendPathComponent("wp-block-editor/v1")
if let namespace = siteApiNamespace.first {
editorSettingsEndpoint.appendPathComponent(namespace)
}

editorSettingsEndpoint.appendPathComponent("settings")
builder = builder.setEditorSettingsEndpoint(editorSettingsEndpoint)
}

if var editorAssetsEndpoint = URL(string: siteApiRoot) {
editorAssetsEndpoint.appendPathComponent("wpcom/v2/")
if let namespace = siteApiNamespace.first {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@

let configuration = EditorConfiguration(blog: blog)
GutenbergKit.EditorViewController.warmup(configuration: configuration)

RawBlockEditorSettingsService(blog: blog).prefetchSettings()
}

// MARK: - Main Blog
Expand Down Expand Up @@ -673,7 +671,7 @@
}

private func makeBlogDetailsViewController(for blog: Blog) -> BlogDetailsViewController {
let blogDetailsViewController = BlogDetailsViewController()

Check warning on line 674 in WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename "blogDetailsViewController" which has the same name as the field declared at line 127.

See more on https://sonarcloud.io/project/issues?id=wordpress-mobile_WordPress-iOS&issues=AZrkTyfCpDw-T5GgYY1U&open=AZrkTyfCpDw-T5GgYY1U&pullRequest=25044
blogDetailsViewController.blog = blog

return blogDetailsViewController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extension CommentGutenbergEditorViewController: GutenbergKit.EditorViewControlle
// Do nothing
}

func editor(_ viewController: GutenbergKit.EditorViewController, didLogMessage message: String, level: GutenbergKit.LogLevel) {
func editor(_ viewController: GutenbergKit.EditorViewController, didLogMessage message: String, level: GutenbergKit.EditorLogLevel) {
// Do nothing
}

Expand All @@ -108,4 +108,8 @@ extension CommentGutenbergEditorViewController: GutenbergKit.EditorViewControlle
func editor(_ viewController: GutenbergKit.EditorViewController, didCloseModalDialog dialogType: String) {
// Do nothing
}

func editor(_ viewController: GutenbergKit.EditorViewController, didLogNetworkRequest request: GutenbergKit.RecordedNetworkRequest) {
// Do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
}

struct EditorDependencies {
let settings: String?
let didLoadCookies: Bool
}

Expand Down Expand Up @@ -100,14 +99,6 @@

let navigationBarManager: PostEditorNavigationBarManager

// MARK: - Private variables

// TODO: reimplemet
// internal private(set) var contentInfo: ContentInfo?
lazy var editorSettingsService: BlockEditorSettingsService? = {
BlockEditorSettingsService(blog: post.blog, coreDataStack: ContextManager.shared)
}()

// MARK: - GutenbergKit

private var editorViewController: GutenbergKit.EditorViewController
Expand Down Expand Up @@ -147,8 +138,6 @@
func setHTML(_ html: String) {}
func getHTML() -> String { post.content ?? "" }

private let blockEditorSettingsService: RawBlockEditorSettingsService

// MARK: - Initializers
required convenience init(
post: AbstractPost,
Expand Down Expand Up @@ -190,8 +179,6 @@
mediaPicker: MediaPickerController(blog: post.blog)
)

self.blockEditorSettingsService = RawBlockEditorSettingsService(blog: post.blog)

super.init(nibName: nil, bundle: nil)

self.editorViewController.delegate = self
Expand Down Expand Up @@ -269,7 +256,7 @@
case .loadingDependencies: preconditionFailure("Dependencies should not still be loading")
case .loadingCancelled: preconditionFailure("Dependency loading should not be cancelled")
case .dependencyError(let error): self.showEditorError(error)
case .dependenciesReady(let dependencies): try await self.startEditor(settings: dependencies.settings)
case .dependenciesReady: try await self.startEditor()
case .started: preconditionFailure("The editor should not already be started")
}
} catch {
Expand Down Expand Up @@ -385,23 +372,18 @@
}

self.editorState = .loadingDependencies(Task {
do {
let dependencies = try await fetchEditorDependencies()
self.editorState = .dependenciesReady(dependencies)
} catch {
self.editorState = .dependencyError(error)
}
let dependencies = await fetchEditorDependencies()
self.editorState = .dependenciesReady(dependencies)
})
}

@MainActor
func startEditor(settings: String?) async throws {
func startEditor() async throws {
guard case .dependenciesReady = self.editorState else {
preconditionFailure("`startEditor` should only be called when the editor is in the `.dependenciesReady` state.")
}

let updatedConfiguration = self.editorViewController.configuration.toBuilder()
.apply(settings) { $0.setEditorSettings($1) }
.setTitle(post.postTitle ?? "")
.setContent(post.content ?? "")
.setNativeInserterEnabled(FeatureFlag.nativeBlockInserter.enabled)
Expand Down Expand Up @@ -481,18 +463,11 @@
}

// MARK: - Editor Setup
private func fetchEditorDependencies() async throws -> EditorDependencies {
let settings: String?
do {
settings = try await blockEditorSettingsService.getSettingsString(allowingCachedResponse: true)
} catch {
DDLogError("Failed to fetch editor settings: \(error)")
settings = nil
}

// TODO: refactor

Check warning on line 467 in WordPress/Classes/ViewRelated/NewGutenberg/NewGutenbergViewController.swift

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=wordpress-mobile_WordPress-iOS&issues=AZrg2QMLLbCMLMQHZixG&open=AZrg2QMLLbCMLMQHZixG&pullRequest=25044
private func fetchEditorDependencies() async -> EditorDependencies {
let loaded = await loadAuthenticationCookiesAsync()

return EditorDependencies(settings: settings, didLoadCookies: loaded)
return EditorDependencies(didLoadCookies: loaded)
}

private func loadAuthenticationCookiesAsync() async -> Bool {
Expand Down Expand Up @@ -573,7 +548,11 @@
}
}

func editor(_ viewController: GutenbergKit.EditorViewController, didLogMessage message: String, level: GutenbergKit.LogLevel) {
func editor(_ viewController: GutenbergKit.EditorViewController, didLogMessage message: String, level: GutenbergKit.EditorLogLevel) {
// Do nothing
}

func editor(_ viewController: GutenbergKit.EditorViewController, didLogNetworkRequest request: GutenbergKit.RecordedNetworkRequest) {
// Do nothing
}

Expand Down