Support most Post Settings on custom posts#25274
Conversation
Generated by 🚫 Danger |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
c482a6f to
07358d1
Compare
3176a05 to
404d35a
Compare
176d0cd to
dbe79cb
Compare
dbe79cb to
ed4b166
Compare
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 31212 | |
| Version | PR #25274 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 2361b90 | |
| Installation URL | 0vp1dhf6sm5c8 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 31212 | |
| Version | PR #25274 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 2361b90 | |
| Installation URL | 3cmq51vhur0kg |
ed4b166 to
4eebb1f
Compare
| service: WordPressAPIInternal.PostService, | ||
| client: WordPressClient, | ||
| post: AnyPostWithEditContext, | ||
| post: AnyPostWithEditContext?, |
There was a problem hiding this comment.
Can an editor be opened without a post? It needs to have an empty starting point. It seems that change resulted in increased complexity.
There was a problem hiding this comment.
AnyPostWithEditContext is fetched from the server. A nil value indicates starting a new post.
|
|
||
| extension CustomPostEditorService { | ||
| // Used in unit tests. | ||
| func inspectPendingSettings() -> PostSettings? { |
There was a problem hiding this comment.
I intentionally made it a function named "inspect" because I don't think it should be used as a public API.
| } | ||
|
|
||
| /// Resolves `id == 0` tags by searching by name. Returns updated tag array. | ||
| private func resolveUnknownTagIDs(for tags: [PostSettings.Term]) async throws -> [PostSettings.Term] { |
There was a problem hiding this comment.
(nit) does it belong to the "editor" service?
There was a problem hiding this comment.
Good point. It probably should be in the TagsService.
|
|
||
| /// Saves or publishes from post settings. Handles term resolution, optional | ||
| /// publish status override with editor content injection, and create-or-update branching. | ||
| func save(settings: PostSettings, publish: Bool) async throws { |
There was a problem hiding this comment.
(nit) It will probably be easier to follow as two separate methods.
(nit) It seems a bit backwards that it stores the settings using PostCreateParams. In the future, the editor will need to be able to support saving local revisions, etc. Shouldn't it simply store PostWithEditrContext with parameters applied locally and then generate "create" parameters from it?
There was a problem hiding this comment.
I think there are many benefits in using different models for different contexts: AnyPostWithEditContext represents an immutable server post, so it should not be used to represent a local draft.
In the future, the editor will need to be able to support saving local revisions,
I haven't thought too much about it at the moment. Maybe we'll refactor once that's implemented, so we can do it properly?
| let service: WordPressAPIInternal.PostService | ||
| let taxonomies: [SiteTaxonomy] | ||
|
|
||
| weak var delegate: CustomPostEditorServiceDelegate? |
There was a problem hiding this comment.
(nit) This also seem a backwards. Maybe it's due to the name. It looks like it's more of a CustomPostEditorViewModel than a service.
There was a problem hiding this comment.
I was thinking about CustomPostEditorSession. The name "session" is used in many Apple APIs, but not so much in this code base. So, I went with the old "service".
|
|
Thanks for the replies! I agree with the get it working -> refactor approach since it's entirely new code. |





Description
Here are the main changes in this PR:
Test Instructions