-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Issues/3786 post list sorting #3810
Conversation
The default postID is -1, not 0.
Shows publish immedately when the date is nil. Shows a "Local" badge. Shows a placeholder title if there is no title or content.
If a post or page has a revision (local changes) display the relevant bits for the revision instead of the original. Let both Post and Page implement WPPostContentViewProvider instead of just Post by moving the relevant bits into AbstractPost. Updates Page related views to support WPPostContentViewProvider instead of WPContentViewProvider.
Adds a core data revision: 31 Adds a new migration mapping and entity migration policy.
@astralbodies Would really appreciate your eyes on the migration policy to make sure its a good approach. |
NSString *key = @"date_created_gmt"; | ||
[self willChangeValueForKey:key]; | ||
[self setPrimitiveValue:date_created_gmt forKey:key]; | ||
[self didChangeValueForKey:key]; |
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.
Since you're supporting KVO, I recently learned that you should register dependent keys with keyPathsForValuesAffecting*
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.
And I think the self.meta* = ...
should be between the willChange
and the didChange
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.
keyPathsForValuesAffecting
Nice find.
I might be missing something, but the |
…OS into issues/3786-post-list-sorting
@aerych This looks okay. I did add a very BASIC unit test to cover migrations from 19 through 31. This does not ensure the data is migrated properly, however. Can you update the unit test to be something similar to |
…mobile/WordPress-iOS into issues/3786-post-list-sorting
Awesome, thanks for that! I'll have a look at the test you mentioned. |
Its intended to cover the edge case when a non-local post (e.g. a draft that already has a remote) is edited to publish immediately, and encounters an error when publishing leaving it in a failed state. In this case the create date would still be nil, but the meta property would be flagged to indicate the correct sort order. |
@astralbodies I've updated the test. Ready for another round. |
@@ -0,0 +1,54 @@ | |||
#import "PostToPost30To31.h" | |||
#import "AbstractPost.h" |
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.
Make sure to not use any model objects in the migration as they are only valid on the most recent model version. I'd remove this import even though its not used.
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.
👍
Thanks guys!! |
Refs #3786
This PR builds on work done in #3805. The relevant changes begin in dd7fa34.
The goal is to add two new helper or "meta" properties to help with sorting posts and pages returned from an NSFetchRequest. The new properties are automatically updated in response to changes to a posts date created or its remote status.
To ensure any existing posts get the correct values set, this PR includes a core data revision, mapping model, and migration policy for posts and pages.
TESTING
Setup: Prepare a local only post in the simulator BEFORE switching to this branch. For convenience, be sure to use a blog with very view posts Follow the steps outlined in this video to create a local-only post https://cloudup.com/iOZ-BQXHqyx
Test 1:
Test 2:
Needs Review: @koke @astralbodies