Skip to content

Commit

Permalink
feat: Synchronize content with GutenbergKit (#23631)
Browse files Browse the repository at this point in the history
* Merge release/25.4 into trunk (#23628)

* Bump version number

* Update draft release notes for 25.4.

* Update draft release notes for 25.4.

* Release Notes: add new section for next version (25.5)

* Update strings for localization

* feat: Persist GutenbergKit changes

Ensure post changes are not lost.

* fix: Persist changes if either post title or content changes

The previous conditional erroneously ignored changes unless both values
changed.

* build: Update GutenbergKit ref

* fix: Improve empty editor content check

As noted in the code comment, this value lags behind reality. A race
condition existed in production builds cause inaccurate values. This was
removed to instead rely upon the existing `editorHasContent`
implementation found in the `PostEditor` class.

* build: Update GutenbergKit ref

* build: Update GutenbergKit ref

* build: Update GutenbergKit ref

* Update GutenbergKit ref

* Update GutenbergKit ref

---------

Co-authored-by: WordPress Mobile Bot Account <[email protected]>
Co-authored-by: Gerardo <[email protected]>
Co-authored-by: Jeremy Massel <[email protected]>
  • Loading branch information
4 people authored Oct 2, 2024
1 parent 039ef74 commit ffeab7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let package = Package(
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-swift-20240813"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "0987aa05587342f531b646dbb36d5622df12cfea"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", revision: "c31879b834ef3ca5ea6b09040c96093ef627e029"),
.package(url: "https://github.com/Automattic/color-studio", branch: "add/swift-file-output"),
],
targets: XcodeSupport.targets + [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/wordpress-mobile/GutenbergKit",
"state" : {
"revision" : "0987aa05587342f531b646dbb36d5622df12cfea"
"revision" : "c31879b834ef3ca5ea6b09040c96093ef627e029"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
return !changes.isEmpty
}

// TODO: this has to be incorrect and/or lagging behind
var editorHasContent: Bool {
!editorViewController.state.isEmpty
}

// TODO: remove (none of these APIs are needed for the new editor)
var autosaver = Autosaver(action: {})
func prepopulateMediaItems(_ media: [Media]) {}
Expand Down Expand Up @@ -294,11 +289,14 @@ class NewGutenbergViewController: UIViewController, PostEditor, PublishingEditor
private func getLatestContent() async {
// TODO: read title as well
let startTime = CFAbsoluteTimeGetCurrent()
let content = try? await editorViewController.getContent()
let editorData = try? await editorViewController.getTitleAndContent()
let duration = CFAbsoluteTimeGetCurrent() - startTime
print("gutenbergkit-measure_get-latest-content:", duration)

if content != post.content {
if let title = editorData?.title,
let content = editorData?.content,
title != post.postTitle || content != post.content {
post.postTitle = title
post.content = content
post.managedObjectContext.map(ContextManager.shared.save)

Expand Down

0 comments on commit ffeab7d

Please sign in to comment.