{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/72143625","id":72143625,"diff_hunk":"@@ -163,40 +170,33 @@ export const queries = ( () => {\n \n \treturn createReducer( {}, {\n \t\t[ POST_RESTORE ]: ( state, { siteId, postId } ) => {\n-\t\t\treturn applyToManager( state, siteId, 'receive', {\n+\t\t\treturn applyToManager( state, siteId, 'receive', false, {\n \t\t\t\tID: postId,\n \t\t\t\tstatus: '__RESTORE_PENDING'\n \t\t\t}, { patch: true } );\n \t\t},\n \t\t[ POST_RESTORE_FAILURE ]: ( state, { siteId, postId } ) => {\n-\t\t\treturn applyToManager( state, siteId, 'receive', {\n+\t\t\treturn applyToManager( state, siteId, 'receive', false, {\n \t\t\t\tID: postId,\n \t\t\t\tstatus: 'trash'\n \t\t\t}, { patch: true } );\n \t\t},\n \t\t[ POSTS_REQUEST_SUCCESS ]: ( state, { siteId, query, posts, found } ) => {\n-\t\t\tif ( ! state[ siteId ] ) {\n-\t\t\t\tstate = {\n-\t\t\t\t\t...state,\n-\t\t\t\t\t[ siteId ]: new PostQueryManager()\n-\t\t\t\t};\n-\t\t\t}\n-\n-\t\t\treturn applyToManager( state, siteId, 'receive', posts, { query, found } );\n+\t\t\treturn applyToManager( state, siteId, 'receive', true, posts, { query, found } );\n \t\t},\n \t\t[ POSTS_RECEIVE ]: ( state, { posts } ) => {\n \t\t\treturn reduce( groupBy( posts, 'site_ID' ), ( memo, sitePosts, siteId ) => {\n-\t\t\t\treturn applyToManager( memo, siteId, 'receive', sitePosts );\n+\t\t\t\treturn applyToManager( memo, siteId, 'receive', true, sitePosts );\n \t\t\t}, state );\n \t\t},\n \t\t[ POST_SAVE ]: ( state, { siteId, postId, post } ) => {\n-\t\t\treturn applyToManager( state, siteId, 'receive', {\n+\t\t\treturn applyToManager( state, siteId, 'receive', false, {\n \t\t\t\tID: postId,\n \t\t\t\t...post\n \t\t\t}, { patch: true } );\n \t\t},\n-\t\t[ POST_DELETE ]: ( state, { siteId, postId } ) => {\n-\t\t\treturn applyToManager( state, siteId, 'removeItem', postId );\n+\t\t[ POST_DELETE_SUCCESS ]: ( state, { siteId, postId } ) => {\n+\t\t\treturn applyToManager( state, siteId, 'removeItem', false, postId );","path":"client/state/posts/reducer.js","position":139,"original_position":139,"commit_id":"993e6eecf9105e1fc7e38151e8fe676287b20e5b","original_commit_id":"993e6eecf9105e1fc7e38151e8fe676287b20e5b","user":{"login":"nylen","id":227022,"avatar_url":"https://avatars.githubusercontent.com/u/227022?v=3","gravatar_id":"","url":"https://api.github.com/users/nylen","html_url":"https://github.com/nylen","followers_url":"https://api.github.com/users/nylen/followers","following_url":"https://api.github.com/users/nylen/following{/other_user}","gists_url":"https://api.github.com/users/nylen/gists{/gist_id}","starred_url":"https://api.github.com/users/nylen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nylen/subscriptions","organizations_url":"https://api.github.com/users/nylen/orgs","repos_url":"https://api.github.com/users/nylen/repos","events_url":"https://api.github.com/users/nylen/events{/privacy}","received_events_url":"https://api.github.com/users/nylen/received_events","type":"User","site_admin":false},"body":"As currently written, `POST_DELETE` is imported but not used.\r\n\r\n```\r\n/Users/james/a8c/code/wp-calypso/client/state/posts/reducer.js\r\n  20:2  warning  'POST_DELETE' is defined but never used  no-unused-vars\r\n```","created_at":"2016-07-25T20:59:20Z","updated_at":"2016-07-25T20:59:20Z","html_url":"https://github.com/Automattic/wp-calypso/pull/6715#discussion_r72143625","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/72143625"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6715#discussion_r72143625"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715","id":77151065,"html_url":"https://github.com/Automattic/wp-calypso/pull/6715","diff_url":"https://github.com/Automattic/wp-calypso/pull/6715.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/6715.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6715","number":6715,"state":"open","locked":false,"title":"State: Consolidate post tracking into query managers","user":{"login":"aduth","id":1779930,"avatar_url":"https://avatars.githubusercontent.com/u/1779930?v=3","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"body":"This pull request seeks to consolidate post tracking into the `posts.queries` state. Currently, post data is duplicated between both `posts.items` and `posts.queries` (`QueryManager` instances). Not only is this a syncing problem, but is also memory wasteful. In order to move forward with state persistence of query data, we should seek to be more efficient with the storage of posts, which is the intent of these changes.\r\n\r\n__Implementation notes:__\r\n\r\nTo continue to allow post lookup by global ID, the `posts.items` state remains but has been transformed in purpose to map to a \"path\" tuple of site ID, post ID pair. While it's true this could have been achieved in a selector instead of storing this in state, it would be very inefficient to look up a post across all sites stored in `posts.queries` to try to find the item matching the global ID.\r\n\r\n__Testing instructions:__\r\n\r\nThere are no visual effects of these changes. Verify that there are no regressions in using either the [custom post types list screen](http://calypso.localhost:3000/types/post) or the [post editor \"Add existing content\" / \"Parent page\" selectors](http://calypso.localhost:3000/post).\r\n\r\nEnsure Mocha tests pass:\r\n\r\n```\r\nnpm run test-client\r\n```\r\n\r\n__Follow-up tasks:__\r\n\r\n- Persist query state\r\n- Implement memoization for `normalizePost` (we memoize the selectors, but this is busted more frequently than desirable and we can probably be more efficient)\n\nTest live: https://calypso.live/?branch=update/state-posts-dedupe","created_at":"2016-07-12T16:45:07Z","updated_at":"2016-07-25T20:59:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e773d8d1e812aab7fcf70e4ec5dad543f8bfde3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6715/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/993e6eecf9105e1fc7e38151e8fe676287b20e5b","head":{"label":"Automattic:update/state-posts-dedupe","ref":"update/state-posts-dedupe","sha":"993e6eecf9105e1fc7e38151e8fe676287b20e5b","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-07-25T16:07:29Z","pushed_at":"2016-07-25T20:55:24Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":82603,"stargazers_count":7606,"watchers_count":7606,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":948,"mirror_url":null,"open_issues_count":1356,"forks":948,"open_issues":1356,"watchers":7606,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"f32efcddb5586f42a336af64bd75d0b3e97948ac","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-07-25T16:07:29Z","pushed_at":"2016-07-25T20:55:24Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":82603,"stargazers_count":7606,"watchers_count":7606,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":948,"mirror_url":null,"open_issues_count":1356,"forks":948,"open_issues":1356,"watchers":7606,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6715"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6715"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6715/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6715/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/993e6eecf9105e1fc7e38151e8fe676287b20e5b"}}}}
{"actor":{"display_login":"nylen"}}