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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [*] Add permalink preview in the slug editor and make other improvements [#24949]
* [*] Add "Taxonomies" to Site Settings [#24955]
* [*] Update "Categories" picker to indicate multiple selection [#24952]
* [*] Fix rare crash on launch when new editor is enabled [#24944]

26.4
-----
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressData/Swift/NSManagedObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public extension NSManagedObject {
return result.flatMap({ ValueType(rawValue: $0) })
}

var locallyUniqueId: String {
var locallyUniqueID: String {
let data = Data(self.objectID.uriRepresentation().absoluteString.utf8)
return SHA256.hash(data: data).compactMap { String(format: "%02x", $0) }.joined()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ final class RawBlockEditorSettingsService {
private var prefetchTask: Task<Void, Never>?

@MainActor
init(blog: Blog) {
self.dotOrgRestAPI = WordPressOrgRestApi(blog: blog)!
self.blogID = blog.locallyUniqueId
init(dotOrgRestAPI: WordPressOrgRestApi, blog: Blog) {
self.dotOrgRestAPI = dotOrgRestAPI
self.blogID = blog.locallyUniqueID
}

private func fetchSettingsFromAPI() async throws -> Data {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ final class MySiteViewController: UIViewController, UIScrollViewDelegate, NoSite
let configuration = EditorConfiguration(blog: blog)
GutenbergKit.EditorViewController.warmup(configuration: configuration)

RawBlockEditorSettingsService(blog: blog).prefetchSettings()
if let dotOrgRestAPI = WordPressOrgRestApi(blog: blog) {
RawBlockEditorSettingsService(dotOrgRestAPI: dotOrgRestAPI, blog: blog)
.prefetchSettings()
}
}

// MARK: - Main Blog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
func setHTML(_ html: String) {}
func getHTML() -> String { post.content ?? "" }

private let blockEditorSettingsService: RawBlockEditorSettingsService
private let blockEditorSettingsService: RawBlockEditorSettingsService?

// MARK: - Initializers
required convenience init(
Expand Down Expand Up @@ -183,7 +183,11 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
let editorConfiguration = EditorConfiguration(blog: post.blog)
self.editorViewController = GutenbergKit.EditorViewController(configuration: editorConfiguration)

self.blockEditorSettingsService = RawBlockEditorSettingsService(blog: post.blog)
if let dotOrgRestAPI = WordPressOrgRestApi(blog: post.blog) {
self.blockEditorSettingsService = RawBlockEditorSettingsService(dotOrgRestAPI: dotOrgRestAPI, blog: post.blog)
} else {
self.blockEditorSettingsService = nil
}

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

Expand Down Expand Up @@ -474,12 +478,13 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor

// 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
var settings: String?
if let blockEditorSettingsService {
do {
settings = try await blockEditorSettingsService.getSettingsString(allowingCachedResponse: true)
} catch {
DDLogError("Failed to fetch editor settings: \(error)")
}
}

let loaded = await loadAuthenticationCookiesAsync()
Expand Down