-
Notifications
You must be signed in to change notification settings - Fork 16
Add autosave attributes to RemotePost #192
Add autosave attributes to RemotePost #192
Conversation
Autosave metadata is supported through the new `meta` option when fetching posts. Autosave metadata currently supported are: `title`, `excerpt`, and `content`.
Simplify the treatment of null values when creating a `RemotePost` from a dictionary representing its JSON data.
I'm unsure if `meta` is supported in XML-RPC, so removing this comment.
Although a good idea, specifying `nullable` triggers warnings on the other properties of this class. To resolve the warnings we would have to either explicitly annotate each property as nullable or nonnull - or, if all properties are not nullable, mark the class with NS_ASSUME_NONNULL_BEGIN.
Update: Autosave is not supported by the XML RPC API. |
shiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's looking good, @guarani. I have a couple of comments.
Do you think it's possible to add a unit test that confirms that the autoSave properties are copied to RemotePost? Probably using a mock JSON like PostServiceRemoteRESTRevisionsTest.
When the fetch posts REST endpoint is called, autosave properties are mapped to the RemotePost object.
|
@shiki, yes. I've now added a test |
shiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, @guarani! I have a couple of minor comments that I'd like to hear your opinion on. After that, this is ready to be merged. 🎉
`open` allowed subclassing of RemotePostAutosave and overriding of its properties, `public` disallows this. Further restiction to disallow setting the properties from outside the module using internal(set) doesn't work due to Obj-C interoperability issues.
|
Thanks again for the review, @shiki! I've updated the PR to address your comments. |
If the fetch posts response JSON returns autosave as null, that's converted to NSNull, which is a truthy value. Updating to treat NSNull as no autosave.
shiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Thank you, @shiki! |
Description
Post autosave attributes are added to
RemotePost- the type that describes a post (or page) fetched from the API. Autosave data is obtained by includingautosavein themetaparameter, but at the time of writing this is undocumented.Issue: wordpress-mobile/WordPress-iOS#12141
REST API
The title, content, excerpt and date of last modification are fetched from the following REST API endpoint:
https://github.com/wordpress-mobile/WordPress-FluxC-Android/pull/1357/files
https://github.com/wordpress-mobile/WordPress-FluxC-Android/pull/1391/files
Testing Details
These changes are best tested alongside the matching WordPress-iOS PR wordpress-mobile/WordPress-iOS#12826
Unit Tests
The new
metaparameter uses the existing mechanism for specifying options,PostServiceRemoteOptions. There is already a test that asserts that arbitrary options are correctly set on the request payload (- testThatGetPostsOfTypeWithOptionsWorks), so I think the current tests have this covered.