{"action":"created","issue":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4840","repository_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4840/labels{/name}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4840/comments","events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4840/events","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4840","id":134117735,"number":4840,"title":"PostService and AbstractPostListViewController Refactor","user":{"login":"kurzee","id":1873422,"avatar_url":"https://avatars.githubusercontent.com/u/1873422?v=3","gravatar_id":"","url":"https://api.github.com/users/kurzee","html_url":"https://github.com/kurzee","followers_url":"https://api.github.com/users/kurzee/followers","following_url":"https://api.github.com/users/kurzee/following{/other_user}","gists_url":"https://api.github.com/users/kurzee/gists{/gist_id}","starred_url":"https://api.github.com/users/kurzee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurzee/subscriptions","organizations_url":"https://api.github.com/users/kurzee/orgs","repos_url":"https://api.github.com/users/kurzee/repos","events_url":"https://api.github.com/users/kurzee/events{/privacy}","received_events_url":"https://api.github.com/users/kurzee/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels/Menus","name":"Menus","color":"f7c6c7"},{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels/Pages%20List","name":"Pages List","color":"0052cc"},{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels/Posts%20List","name":"Posts List","color":"0052cc"},{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/labels/[Type]%20Enhancement","name":"[Type] Enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones/52","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/milestones/6.1","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/milestones/52/labels","id":1560794,"number":52,"title":"6.1","description":null,"creator":{"login":"koke","id":8739,"avatar_url":"https://avatars.githubusercontent.com/u/8739?v=3","gravatar_id":"","url":"https://api.github.com/users/koke","html_url":"https://github.com/koke","followers_url":"https://api.github.com/users/koke/followers","following_url":"https://api.github.com/users/koke/following{/other_user}","gists_url":"https://api.github.com/users/koke/gists{/gist_id}","starred_url":"https://api.github.com/users/koke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koke/subscriptions","organizations_url":"https://api.github.com/users/koke/orgs","repos_url":"https://api.github.com/users/koke/repos","events_url":"https://api.github.com/users/koke/events{/privacy}","received_events_url":"https://api.github.com/users/koke/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":23,"state":"open","created_at":"2016-02-03T10:53:06Z","updated_at":"2016-02-17T18:18:08Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-02-16T22:45:31Z","updated_at":"2016-02-17T18:30:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/pulls/4840","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4840","diff_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4840.diff","patch_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4840.patch"},"body":"Originally, the `PostService` implementation did a couple things in which it managed paging of posts itself. In some sense, this just about attempted to manage its own state by paging requests based on whatever oldest post happened to be in CoreData, and also with purging any posts that weren't a part of a sync or paging request.\r\n\r\nThe above was an issue while implementing a new endpoint within `PostService` for searching posts. Searching posts created an issue because resulting posts would break the assumed paging of `PostService` implementation.\r\n\r\nThe primary refactor of this PR is within `PostService` and separating the use of sync and paging parameters instead on users of `PostService` via a new object parameter class `PostServiceOptions`. \r\n\r\nThe secondary refactor is within `AbstractPostListViewController` and its supporting files, due to how intertwined the previous `PostService` sync, paging, and purge implementation were. `AbstractPostListViewController` now handles paging on its own and filters posts according to the sync results. Particularly, posts that are older than the `oldestPostDate` are filtered out of the `NSFetchRequest` to ensure posts arbitrarily loaded into CoreData are not displayed in a paged list (search results).\r\n\r\nAdditional refactoring includes method naming cleanup, use of generics and a bit of code-cleanup for clarity of what's going on.\r\n\r\n**Testing:**\r\n1. Open \"Blog Posts\", posts should load normally and in order from newest to oldest.\r\n2. Scroll down the bottom of the list, older posts should load in order.\r\n3. Continuing scrolling to load old posts until a desirable depth is reached.\r\n4. Select either \"Everyone\" or \"Only\" in the segmented control above.\r\n5. Posts should behave as expected as in steps 1, 2, 3.\r\n6. Switch back to the previous segmented control option, the post list should be at the top and paging should continue where you left off for either segment control option.\r\n7. Select a post to view it, go back, post list should maintain scroll position except for significant updates of ordering (unlikely).\r\n8. Create a new post and post it, post should show up at the top of the list.\r\n9. Select different post filters from the drop down, posts should display, page and order as expected.\r\n10. Go back to the Site menu and select \"Pages\". Everything should work as expected 😎.\r\n\r\nPlease review @aerych 💥💥💥💥💥"},"comment":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/comments/185339389","html_url":"https://github.com/wordpress-mobile/WordPress-iOS/pull/4840#issuecomment-185339389","issue_url":"https://api.github.com/repos/wordpress-mobile/WordPress-iOS/issues/4840","id":185339389,"user":{"login":"aerych","id":1435271,"avatar_url":"https://avatars.githubusercontent.com/u/1435271?v=3","gravatar_id":"","url":"https://api.github.com/users/aerych","html_url":"https://github.com/aerych","followers_url":"https://api.github.com/users/aerych/followers","following_url":"https://api.github.com/users/aerych/following{/other_user}","gists_url":"https://api.github.com/users/aerych/gists{/gist_id}","starred_url":"https://api.github.com/users/aerych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerych/subscriptions","organizations_url":"https://api.github.com/users/aerych/orgs","repos_url":"https://api.github.com/users/aerych/repos","events_url":"https://api.github.com/users/aerych/events{/privacy}","received_events_url":"https://api.github.com/users/aerych/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T18:30:58Z","updated_at":"2016-02-17T18:30:58Z","body":"Hiya @kurzee :)  I'm liking the changes.  I had a couple of questions I left in the diff.  I also noticed a few things while testing:\r\n\r\nThe first time the list is opened:\r\n- Scrolling to the bottom of the list does not show the spinner while syncing additional posts. \r\n- Scrolling to the bottom of the list when there are no more posts to load does not show the footer\r\n\r\nAfter a pull-to-refresh action the footer is visible in both scenarios.\r\n\r\nAlso,\r\n\r\n- Posts deleted on the web do not seem to be cleaned up / purged from core data.   To reproduce,\r\n - Open the list in the app to published\r\n - Open the post list in wp-admin on the web and delete a post. Make sure to delete it permanently.\r\n - Back in the app, pull to refresh. Notice that the post is still present.\r\n- If post’s status is changed on the web (a published post is set to a draft status) the post still appears in the original list until switch to the updated list.  To reproduce:\r\n - Open the post list in the app to published.\r\n - In wp-admin, edit a post. Change it status to draft or pending review. \r\n - Back in the app, pull to refresh. Notice the post still is in the published list. \r\n - Now switch to the draft list. Notice the post is present here.\r\n - Switch back to the published list and the post is gone. \r\n"}}