-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
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 |
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.
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 includingautosave
in themeta
parameter, 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
meta
parameter 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.