{"action":"created","comment":{"url":"https://api.github.com/repos/Yoast/yoast-components/pulls/comments/199872843","pull_request_review_id":134077611,"id":199872843,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTg3Mjg0Mw==","diff_hunk":"@@ -0,0 +1,77 @@\n+import {\n+\tSET_SYNONYMS,\n+\tADD_SYNONYMS,\n+\tINSERT_SYNONYMS,\n+\tCHANGE_SYNONYMS,\n+\tREMOVE_SYNONYMS,\n+} from \"../actions/synonyms\";\n+\n+const INITIAL_STATE = [];\n+\n+/**\n+ * Checks if an index is inside the array.\n+ *\n+ * @param {array}  arr   The array to check in.\n+ * @param {number} index The index to check for.\n+ *\n+ * @returns {boolean} Whether the index exists in the array or not.\n+ */\n+function indexInArray( arr, index ) {\n+\treturn index < 0 && index > arr.length;\n+}\n+\n+/* eslint-disable complexity */\n+/**\n+ * A reducer for the synonyms.\n+ *\n+ * @param {Object} state  The current state of the object.\n+ * @param {Object} action The current action received.\n+ *\n+ * @returns {Object} The state.\n+ */\n+function synonymsReducer( state = INITIAL_STATE, action ) {\n+\tswitch( action.type ) {\n+\t\tcase SET_SYNONYMS:\n+\t\t\treturn action.synonyms;\n+\n+\t\tcase ADD_SYNONYMS:\n+\t\t\treturn [ ...state, action.synonyms ];\n+\n+\t\tcase INSERT_SYNONYMS:\n+\t\t\tif ( indexInArray( state, action.index ) ) {\n+\t\t\t\treturn state;\n+\t\t\t}\n+\n+\t\t\treturn [\n+\t\t\t\t...state.slice( 0, action.index ),\n+\t\t\t\taction.synonyms,\n+\t\t\t\t...state.slice( action.index ),\n+\t\t\t];\n+\n+\t\tcase CHANGE_SYNONYMS:\n+\t\t\tif ( indexInArray( state, action.index ) ) {\n+\t\t\t\treturn state;\n+\t\t\t}\n+\n+\t\t\treturn [\n+\t\t\t\t...state.slice( 0, action.index ),\n+\t\t\t\taction.synonyms,\n+\t\t\t\t...state.slice( action.index + 1 ),\n+\t\t\t];\n+\n+\t\tcase REMOVE_SYNONYMS:\n+\t\t\tif ( indexInArray( state, action.index ) ) {\n+\t\t\t\treturn state;\n+\t\t\t}\n+\n+\t\t\treturn [\n+\t\t\t\t...state.slice( 0, action.index ),\n+\t\t\t\t...state.slice( action.index + 1 ),\n+\t\t\t];","path":"composites/Plugin/Synonyms/reducers/synonyms.js","position":70,"original_position":70,"commit_id":"09b4ef5444a08133b589f8dc595a5bef374a994c","original_commit_id":"6d79b439721414ac44623585be6245a123804721","user":{"login":"igorschoester","id":35524806,"node_id":"MDQ6VXNlcjM1NTI0ODA2","avatar_url":"https://avatars1.githubusercontent.com/u/35524806?v=4","gravatar_id":"","url":"https://api.github.com/users/igorschoester","html_url":"https://github.com/igorschoester","followers_url":"https://api.github.com/users/igorschoester/followers","following_url":"https://api.github.com/users/igorschoester/following{/other_user}","gists_url":"https://api.github.com/users/igorschoester/gists{/gist_id}","starred_url":"https://api.github.com/users/igorschoester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorschoester/subscriptions","organizations_url":"https://api.github.com/users/igorschoester/orgs","repos_url":"https://api.github.com/users/igorschoester/repos","events_url":"https://api.github.com/users/igorschoester/events{/privacy}","received_events_url":"https://api.github.com/users/igorschoester/received_events","type":"User","site_admin":false},"body":"Splice changes the original, where slice returns a new array. In reducers you should never alter the original state. More info here: https://github.com/reduxjs/redux/blob/master/docs/recipes/reducers/ImmutableUpdatePatterns.md","created_at":"2018-07-03T16:31:13Z","updated_at":"2018-07-03T16:31:13Z","html_url":"https://github.com/Yoast/yoast-components/pull/625#discussion_r199872843","pull_request_url":"https://api.github.com/repos/Yoast/yoast-components/pulls/625","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/comments/199872843"},"html":{"href":"https://github.com/Yoast/yoast-components/pull/625#discussion_r199872843"},"pull_request":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/625"}},"in_reply_to_id":199814148},"pull_request":{"url":"https://api.github.com/repos/Yoast/yoast-components/pulls/625","id":197778034,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3Nzc4MDM0","html_url":"https://github.com/Yoast/yoast-components/pull/625","diff_url":"https://github.com/Yoast/yoast-components/pull/625.diff","patch_url":"https://github.com/Yoast/yoast-components/pull/625.patch","issue_url":"https://api.github.com/repos/Yoast/yoast-components/issues/625","number":625,"state":"closed","locked":false,"title":"Add Synonyms component","user":{"login":"nataliashitova","id":36954173,"node_id":"MDQ6VXNlcjM2OTU0MTcz","avatar_url":"https://avatars0.githubusercontent.com/u/36954173?v=4","gravatar_id":"","url":"https://api.github.com/users/nataliashitova","html_url":"https://github.com/nataliashitova","followers_url":"https://api.github.com/users/nataliashitova/followers","following_url":"https://api.github.com/users/nataliashitova/following{/other_user}","gists_url":"https://api.github.com/users/nataliashitova/gists{/gist_id}","starred_url":"https://api.github.com/users/nataliashitova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nataliashitova/subscriptions","organizations_url":"https://api.github.com/users/nataliashitova/orgs","repos_url":"https://api.github.com/users/nataliashitova/repos","events_url":"https://api.github.com/users/nataliashitova/events{/privacy}","received_events_url":"https://api.github.com/users/nataliashitova/received_events","type":"User","site_admin":false},"body":"## Summary\r\n\r\nThis PR can be summarized in the following changelog entry:\r\n\r\n* Adds synonyms components.\r\n\r\n## Relevant technical choices:\r\n\r\n* Adds SynonymsSection and SynonymsInput components.\r\n* Adds a synonym redux action and reducer.\r\n\r\n## Test instructions\r\n\r\nThis PR can be tested by following these steps:\r\n\r\n* Check the standalone under the tab \"Keyword\".\r\n* Type something in the synonyms input and see the console log.\r\n\r\nFixes #622 \r\n","created_at":"2018-06-27T15:51:55Z","updated_at":"2018-07-03T16:31:13Z","closed_at":"2018-07-03T15:05:21Z","merged_at":"2018-07-03T15:05:21Z","merge_commit_sha":"74d20f959d799c1612f09e824a9427c26e0f61c6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/Yoast/yoast-components/milestones/60","html_url":"https://github.com/Yoast/yoast-components/milestone/60","labels_url":"https://api.github.com/repos/Yoast/yoast-components/milestones/60/labels","id":3467423,"node_id":"MDk6TWlsZXN0b25lMzQ2NzQyMw==","number":60,"title":"4.7","description":null,"creator":{"login":"IreneStr","id":17744553,"node_id":"MDQ6VXNlcjE3NzQ0NTUz","avatar_url":"https://avatars3.githubusercontent.com/u/17744553?v=4","gravatar_id":"","url":"https://api.github.com/users/IreneStr","html_url":"https://github.com/IreneStr","followers_url":"https://api.github.com/users/IreneStr/followers","following_url":"https://api.github.com/users/IreneStr/following{/other_user}","gists_url":"https://api.github.com/users/IreneStr/gists{/gist_id}","starred_url":"https://api.github.com/users/IreneStr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IreneStr/subscriptions","organizations_url":"https://api.github.com/users/IreneStr/orgs","repos_url":"https://api.github.com/users/IreneStr/repos","events_url":"https://api.github.com/users/IreneStr/events{/privacy}","received_events_url":"https://api.github.com/users/IreneStr/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":4,"state":"open","created_at":"2018-07-02T14:12:20Z","updated_at":"2018-07-03T15:05:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Yoast/yoast-components/pulls/625/commits","review_comments_url":"https://api.github.com/repos/Yoast/yoast-components/pulls/625/comments","review_comment_url":"https://api.github.com/repos/Yoast/yoast-components/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Yoast/yoast-components/issues/625/comments","statuses_url":"https://api.github.com/repos/Yoast/yoast-components/statuses/09b4ef5444a08133b589f8dc595a5bef374a994c","head":{"label":"Yoast:create-synonym-input-field","ref":"create-synonym-input-field","sha":"09b4ef5444a08133b589f8dc595a5bef374a994c","user":{"login":"Yoast","id":4690436,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2OTA0MzY=","avatar_url":"https://avatars0.githubusercontent.com/u/4690436?v=4","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"repo":{"id":64846946,"node_id":"MDEwOlJlcG9zaXRvcnk2NDg0Njk0Ng==","name":"yoast-components","full_name":"Yoast/yoast-components","owner":{"login":"Yoast","id":4690436,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2OTA0MzY=","avatar_url":"https://avatars0.githubusercontent.com/u/4690436?v=4","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yoast/yoast-components","description":"Accessible React components by Yoast","fork":false,"url":"https://api.github.com/repos/Yoast/yoast-components","forks_url":"https://api.github.com/repos/Yoast/yoast-components/forks","keys_url":"https://api.github.com/repos/Yoast/yoast-components/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yoast/yoast-components/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yoast/yoast-components/teams","hooks_url":"https://api.github.com/repos/Yoast/yoast-components/hooks","issue_events_url":"https://api.github.com/repos/Yoast/yoast-components/issues/events{/number}","events_url":"https://api.github.com/repos/Yoast/yoast-components/events","assignees_url":"https://api.github.com/repos/Yoast/yoast-components/assignees{/user}","branches_url":"https://api.github.com/repos/Yoast/yoast-components/branches{/branch}","tags_url":"https://api.github.com/repos/Yoast/yoast-components/tags","blobs_url":"https://api.github.com/repos/Yoast/yoast-components/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yoast/yoast-components/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yoast/yoast-components/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yoast/yoast-components/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yoast/yoast-components/statuses/{sha}","languages_url":"https://api.github.com/repos/Yoast/yoast-components/languages","stargazers_url":"https://api.github.com/repos/Yoast/yoast-components/stargazers","contributors_url":"https://api.github.com/repos/Yoast/yoast-components/contributors","subscribers_url":"https://api.github.com/repos/Yoast/yoast-components/subscribers","subscription_url":"https://api.github.com/repos/Yoast/yoast-components/subscription","commits_url":"https://api.github.com/repos/Yoast/yoast-components/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yoast/yoast-components/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yoast/yoast-components/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yoast/yoast-components/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yoast/yoast-components/contents/{+path}","compare_url":"https://api.github.com/repos/Yoast/yoast-components/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yoast/yoast-components/merges","archive_url":"https://api.github.com/repos/Yoast/yoast-components/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yoast/yoast-components/downloads","issues_url":"https://api.github.com/repos/Yoast/yoast-components/issues{/number}","pulls_url":"https://api.github.com/repos/Yoast/yoast-components/pulls{/number}","milestones_url":"https://api.github.com/repos/Yoast/yoast-components/milestones{/number}","notifications_url":"https://api.github.com/repos/Yoast/yoast-components/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yoast/yoast-components/labels{/name}","releases_url":"https://api.github.com/repos/Yoast/yoast-components/releases{/id}","deployments_url":"https://api.github.com/repos/Yoast/yoast-components/deployments","created_at":"2016-08-03T13:10:33Z","updated_at":"2018-07-03T15:27:50Z","pushed_at":"2018-07-03T15:27:59Z","git_url":"git://github.com/Yoast/yoast-components.git","ssh_url":"git@github.com:Yoast/yoast-components.git","clone_url":"https://github.com/Yoast/yoast-components.git","svn_url":"https://github.com/Yoast/yoast-components","homepage":"","size":3760,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":5,"open_issues":109,"watchers":19,"default_branch":"develop"}},"base":{"label":"Yoast:develop","ref":"develop","sha":"3ab7e62ded0fdd399dc8e3237802678f36d218e2","user":{"login":"Yoast","id":4690436,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2OTA0MzY=","avatar_url":"https://avatars0.githubusercontent.com/u/4690436?v=4","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"repo":{"id":64846946,"node_id":"MDEwOlJlcG9zaXRvcnk2NDg0Njk0Ng==","name":"yoast-components","full_name":"Yoast/yoast-components","owner":{"login":"Yoast","id":4690436,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2OTA0MzY=","avatar_url":"https://avatars0.githubusercontent.com/u/4690436?v=4","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yoast/yoast-components","description":"Accessible React components by Yoast","fork":false,"url":"https://api.github.com/repos/Yoast/yoast-components","forks_url":"https://api.github.com/repos/Yoast/yoast-components/forks","keys_url":"https://api.github.com/repos/Yoast/yoast-components/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yoast/yoast-components/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yoast/yoast-components/teams","hooks_url":"https://api.github.com/repos/Yoast/yoast-components/hooks","issue_events_url":"https://api.github.com/repos/Yoast/yoast-components/issues/events{/number}","events_url":"https://api.github.com/repos/Yoast/yoast-components/events","assignees_url":"https://api.github.com/repos/Yoast/yoast-components/assignees{/user}","branches_url":"https://api.github.com/repos/Yoast/yoast-components/branches{/branch}","tags_url":"https://api.github.com/repos/Yoast/yoast-components/tags","blobs_url":"https://api.github.com/repos/Yoast/yoast-components/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yoast/yoast-components/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yoast/yoast-components/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yoast/yoast-components/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yoast/yoast-components/statuses/{sha}","languages_url":"https://api.github.com/repos/Yoast/yoast-components/languages","stargazers_url":"https://api.github.com/repos/Yoast/yoast-components/stargazers","contributors_url":"https://api.github.com/repos/Yoast/yoast-components/contributors","subscribers_url":"https://api.github.com/repos/Yoast/yoast-components/subscribers","subscription_url":"https://api.github.com/repos/Yoast/yoast-components/subscription","commits_url":"https://api.github.com/repos/Yoast/yoast-components/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yoast/yoast-components/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yoast/yoast-components/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yoast/yoast-components/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yoast/yoast-components/contents/{+path}","compare_url":"https://api.github.com/repos/Yoast/yoast-components/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yoast/yoast-components/merges","archive_url":"https://api.github.com/repos/Yoast/yoast-components/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yoast/yoast-components/downloads","issues_url":"https://api.github.com/repos/Yoast/yoast-components/issues{/number}","pulls_url":"https://api.github.com/repos/Yoast/yoast-components/pulls{/number}","milestones_url":"https://api.github.com/repos/Yoast/yoast-components/milestones{/number}","notifications_url":"https://api.github.com/repos/Yoast/yoast-components/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yoast/yoast-components/labels{/name}","releases_url":"https://api.github.com/repos/Yoast/yoast-components/releases{/id}","deployments_url":"https://api.github.com/repos/Yoast/yoast-components/deployments","created_at":"2016-08-03T13:10:33Z","updated_at":"2018-07-03T15:27:50Z","pushed_at":"2018-07-03T15:27:59Z","git_url":"git://github.com/Yoast/yoast-components.git","ssh_url":"git@github.com:Yoast/yoast-components.git","clone_url":"https://github.com/Yoast/yoast-components.git","svn_url":"https://github.com/Yoast/yoast-components","homepage":"","size":3760,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":5,"open_issues":109,"watchers":19,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/625"},"html":{"href":"https://github.com/Yoast/yoast-components/pull/625"},"issue":{"href":"https://api.github.com/repos/Yoast/yoast-components/issues/625"},"comments":{"href":"https://api.github.com/repos/Yoast/yoast-components/issues/625/comments"},"review_comments":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/625/comments"},"review_comment":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Yoast/yoast-components/pulls/625/commits"},"statuses":{"href":"https://api.github.com/repos/Yoast/yoast-components/statuses/09b4ef5444a08133b589f8dc595a5bef374a994c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"igorschoester"}}