{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/53984851","id":53984851,"diff_hunk":"@@ -0,0 +1,176 @@\n+/**\n+ * External dependencies\n+ */\n+import Immutable from 'immutable';\n+import { combineReducers } from 'redux';\n+\n+/**\n+ * Internal dependencies\n+ */\n+import {\n+\tCOMMENTS_RECEIVE,\n+\tCOMMENTS_REMOVE,\n+\tCOMMENTS_ERROR,\n+\tCOMMENTS_COUNT_RECEIVE,\n+\tCOMMENTS_LIKE,\n+\tCOMMENTS_LIKE_UPDATE,\n+\tCOMMENTS_UNLIKE,\n+\tCOMMENTS_REQUEST,\n+\tCOMMENTS_REQUEST_SUCCESS,\n+\tCOMMENTS_REQUEST_FAILURE,\n+\tDESERIALIZE,\n+\tSERIALIZE,\n+} from '../action-types';\n+import {\n+\tcreateCommentTargetId,\n+\tlistFindAndModify\n+} from './utils';\n+import {\n+\tPLACEHOLDER_STATE\n+} from './constants';\n+\n+/***\n+ * Creates a function that updates like count\n+ * @param {Boolean} like true to like, false to unlike\n+ * @returns {Function} function that updates like count for comment\n+ */\n+function getLikeSetter( { like = true, likeCount } ) {\n+\treturn ( comment ) => comment.set( 'i_like', like )\n+\t\t\t\t\t\t\t\t.update( 'like_count', ( ct ) => {\n+\t\t\t\t\t\t\t\t\tif ( typeof likeCount !== 'undefined' ) {\n+\t\t\t\t\t\t\t\t\t\treturn likeCount;\n+\t\t\t\t\t\t\t\t\t}\n+\n+\t\t\t\t\t\t\t\t\treturn like ? ct + 1 : ct - 1;\n+\t\t\t\t\t\t\t\t} );\n+}\n+\n+/***\n+ * Updates a specific state in the general state\n+ * @param {Immutable.Map} state general state for all commentTargetId\n+ * @param {Object} action action object\n+ * @param {Number} action.siteId site identifier\n+ * @param {Number} action.postId post identifier\n+ * @param {Function|Object} updaterOrValue an updater function or a value\n+ * @returns {Immutable.Map} new state\n+ */\n+function updateSpecificState( state, action, updaterOrValue ) {","path":"client/state/comments/reducer.js","position":57,"original_position":57,"commit_id":"88b2d5e3460cf694cf5caf28d5fd73fbb1a6bbf6","original_commit_id":"482cc9e2c873249fb9e73f4fd1d391db4921058f","user":{"login":"gwwar","id":1270189,"avatar_url":"https://avatars.githubusercontent.com/u/1270189?v=3","gravatar_id":"","url":"https://api.github.com/users/gwwar","html_url":"https://github.com/gwwar","followers_url":"https://api.github.com/users/gwwar/followers","following_url":"https://api.github.com/users/gwwar/following{/other_user}","gists_url":"https://api.github.com/users/gwwar/gists{/gist_id}","starred_url":"https://api.github.com/users/gwwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwwar/subscriptions","organizations_url":"https://api.github.com/users/gwwar/orgs","repos_url":"https://api.github.com/users/gwwar/repos","events_url":"https://api.github.com/users/gwwar/events{/privacy}","received_events_url":"https://api.github.com/users/gwwar/received_events","type":"User","site_admin":false},"body":"Passing exactly what the function needs, helps keep the intent clearer and makes refactoring easier. This is a helper function, so not a blocker here.","created_at":"2016-02-24T18:41:25Z","updated_at":"2016-02-24T18:41:25Z","html_url":"https://github.com/Automattic/wp-calypso/pull/3143#discussion_r53984851","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/53984851"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/3143#discussion_r53984851"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143","id":58523955,"html_url":"https://github.com/Automattic/wp-calypso/pull/3143","diff_url":"https://github.com/Automattic/wp-calypso/pull/3143.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/3143.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/3143","number":3143,"state":"open","locked":false,"title":"Add redux comments store","user":{"login":"samuelclemens","id":16884350,"avatar_url":"https://avatars.githubusercontent.com/u/16884350?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelclemens","html_url":"https://github.com/samuelclemens","followers_url":"https://api.github.com/users/samuelclemens/followers","following_url":"https://api.github.com/users/samuelclemens/following{/other_user}","gists_url":"https://api.github.com/users/samuelclemens/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelclemens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelclemens/subscriptions","organizations_url":"https://api.github.com/users/samuelclemens/orgs","repos_url":"https://api.github.com/users/samuelclemens/repos","events_url":"https://api.github.com/users/samuelclemens/events{/privacy}","received_events_url":"https://api.github.com/users/samuelclemens/received_events","type":"User","site_admin":false},"body":"This PR lays some ground work for issues #2839, #967, and #792 .\r\nCurrent status is that the code is mainly done, what left IMO, are some style adjustments and documentation. \r\nYour opinion is appreciated.\r\n\r\n#2839:\r\nThe comments pulled by date in DESCending order, while a tree of comments is being build in the store.\r\nThis is achieved by calling `requestPostComments()` action creator, subsequent calls will fetch the earlier (older) dated comments.\r\n\r\n#967:\r\nThe comments are built in a tree-like structure, that allows us to see in each comment which are it's children and how many children the comment has.\r\n\r\nIt can be used something like [that](https://github.com/samuelclemens/wp-calypso/blob/add/comments-redux/client/reader/comments-redux/index.jsx#L36-L50):\r\n```\r\nconst commentChildrenIds = this.props.comments.getIn( [ this.props.commentId, 'children' ] ).toJS();\r\n\r\nif ( commentChildrenIds.length > 0 ) {\r\n\tif ( this.state.viewReplies ) {\r\n\t\treturn <ol>\r\n\t\t\t\t{ commentChildrenIds.reverse().map( ( commentId ) => <Comment ... /> ) }\r\n\t\t\t\t</ol>\r\n\t} else {\r\n\t\treturn <button onClick={ this.viewRepliesClickHandler.bind( this ) }> view { commentChildrenIds.length } replies</button>;\r\n\t}\r\n}\r\n```\r\n\r\n<del>\r\n#792:\r\nPolling can be done by invoking `pollComments()` action creator ( from `<Interval />` maybe? ) after first `requestPostComments()`, it'll fetch the new comments ( comments that got approved and meet the time-frame and entirely new comments ) and remove comments that got unapproved.\r\n\r\nIt is very inefficient however, and  it also can't detect edited comments.\r\n</del>\r\nNo polling support in this PR.","created_at":"2016-02-06T16:38:30Z","updated_at":"2016-02-24T18:41:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9eea290e15db995e5f615afdefe505e421dad9b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143/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/3143/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/88b2d5e3460cf694cf5caf28d5fd73fbb1a6bbf6","head":{"label":"samuelclemens:add/redux-comments","ref":"add/redux-comments","sha":"88b2d5e3460cf694cf5caf28d5fd73fbb1a6bbf6","user":{"login":"samuelclemens","id":16884350,"avatar_url":"https://avatars.githubusercontent.com/u/16884350?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelclemens","html_url":"https://github.com/samuelclemens","followers_url":"https://api.github.com/users/samuelclemens/followers","following_url":"https://api.github.com/users/samuelclemens/following{/other_user}","gists_url":"https://api.github.com/users/samuelclemens/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelclemens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelclemens/subscriptions","organizations_url":"https://api.github.com/users/samuelclemens/orgs","repos_url":"https://api.github.com/users/samuelclemens/repos","events_url":"https://api.github.com/users/samuelclemens/events{/privacy}","received_events_url":"https://api.github.com/users/samuelclemens/received_events","type":"User","site_admin":false},"repo":{"id":50390378,"name":"wp-calypso","full_name":"samuelclemens/wp-calypso","owner":{"login":"samuelclemens","id":16884350,"avatar_url":"https://avatars.githubusercontent.com/u/16884350?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelclemens","html_url":"https://github.com/samuelclemens","followers_url":"https://api.github.com/users/samuelclemens/followers","following_url":"https://api.github.com/users/samuelclemens/following{/other_user}","gists_url":"https://api.github.com/users/samuelclemens/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelclemens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelclemens/subscriptions","organizations_url":"https://api.github.com/users/samuelclemens/orgs","repos_url":"https://api.github.com/users/samuelclemens/repos","events_url":"https://api.github.com/users/samuelclemens/events{/privacy}","received_events_url":"https://api.github.com/users/samuelclemens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samuelclemens/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":true,"url":"https://api.github.com/repos/samuelclemens/wp-calypso","forks_url":"https://api.github.com/repos/samuelclemens/wp-calypso/forks","keys_url":"https://api.github.com/repos/samuelclemens/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samuelclemens/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samuelclemens/wp-calypso/teams","hooks_url":"https://api.github.com/repos/samuelclemens/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/samuelclemens/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/samuelclemens/wp-calypso/events","assignees_url":"https://api.github.com/repos/samuelclemens/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/samuelclemens/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/samuelclemens/wp-calypso/tags","blobs_url":"https://api.github.com/repos/samuelclemens/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samuelclemens/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samuelclemens/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/samuelclemens/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samuelclemens/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/samuelclemens/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/samuelclemens/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/samuelclemens/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/samuelclemens/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/samuelclemens/wp-calypso/subscription","commits_url":"https://api.github.com/repos/samuelclemens/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/samuelclemens/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/samuelclemens/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/samuelclemens/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/samuelclemens/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/samuelclemens/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samuelclemens/wp-calypso/merges","archive_url":"https://api.github.com/repos/samuelclemens/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samuelclemens/wp-calypso/downloads","issues_url":"https://api.github.com/repos/samuelclemens/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/samuelclemens/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/samuelclemens/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/samuelclemens/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samuelclemens/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/samuelclemens/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/samuelclemens/wp-calypso/deployments","created_at":"2016-01-26T00:10:24Z","updated_at":"2016-01-26T00:10:29Z","pushed_at":"2016-02-24T18:09:08Z","git_url":"git://github.com/samuelclemens/wp-calypso.git","ssh_url":"git@github.com:samuelclemens/wp-calypso.git","clone_url":"https://github.com/samuelclemens/wp-calypso.git","svn_url":"https://github.com/samuelclemens/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":13366,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"95aa72b11897a595917f6216c06492fcd370732a","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-02-24T18:13:47Z","pushed_at":"2016-02-24T18:33:19Z","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":55881,"stargazers_count":6858,"watchers_count":6858,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":792,"mirror_url":null,"open_issues_count":1241,"forks":792,"open_issues":1241,"watchers":6858,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/3143"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/3143"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/3143/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/3143/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/3143/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/88b2d5e3460cf694cf5caf28d5fd73fbb1a6bbf6"}}}}