{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/6395","repository_url":"https://api.github.com/repos/WordPress/gutenberg","labels_url":"https://api.github.com/repos/WordPress/gutenberg/issues/6395/labels{/name}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/6395/comments","events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/6395/events","html_url":"https://github.com/WordPress/gutenberg/pull/6395","id":317339956,"node_id":"MDExOlB1bGxSZXF1ZXN0MTgzODIyMTU1","number":6395,"title":"Framework: Add queried-data state helper utility","user":{"login":"aduth","id":1779930,"node_id":"MDQ6VXNlcjE3Nzk5MzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1779930?v=4","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},"labels":[{"id":562969841,"node_id":"MDU6TGFiZWw1NjI5Njk4NDE=","url":"https://api.github.com/repos/WordPress/gutenberg/labels/Framework","name":"Framework","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-24T18:17:45Z","updated_at":"2018-06-12T10:19:19Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/6395","html_url":"https://github.com/WordPress/gutenberg/pull/6395","diff_url":"https://github.com/WordPress/gutenberg/pull/6395.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/6395.patch"},"body":"Related: #6180 \r\nRelated: #6360\r\n\r\nThis pull request seeks to work toward a generalized solution for queried / paginated data resources. It is implemented as an independent (but currently bundled) set of state helpers, including reducer, selectors, and action creators for operating on queried data. Currently, only the categories data has been refactored, and it does not currently take advantage of pagination (as this is not used by the Categories block). Further, as discovered in #6360, some additional work is required for memoization of \"same\" (but not strictly equal) query fulfillment.\r\n\r\nThe hope is that each resource (`core-data` state key) can simply reuse the existing helpers from `queried-data`. For terms, this looks like:\r\n\r\n```js\r\nexport const terms = onSubKey( 'taxonomy' )( queriedDataReducer );\r\n```\r\n\r\nSome additional helpers may be required to expand this out to other state like media, particularly for ensuring that the reducer only operates on relevant queried data. For terms this is handled automatically through the `onSubKey` higher-order reducer creator, where state is only tracked for actions which include a `taxonomy` property. Likewise, we may create other higher-order reducers which test for the presence of some resource-specific marker, to be applied as an extension of the baseline `receiveQueriedItems` action creator (e.g. `ifActionMatches( ( action ) => action.queried === 'media' )`).\r\n\r\nThe state shape is normalized, with queries tracked as stable keys, both to avoid storing redundant data, and to avoid duplicate tracking for equivalent queries:\r\n\r\nExample:\r\n\r\n```json\r\n{\r\n\t\"terms\": {\r\n\t\t\"categories\": {\r\n\t\t\t\"items\": {\r\n\t\t\t\t\"1\": {\r\n\t\t\t\t\t\"id\": 1,\r\n\t\t\t\t\t\"name\": \"Uncategorized\"\r\n\t\t\t\t},\r\n\t\t\t\t\"2\": {\r\n\t\t\t\t\t\"id\": 2,\r\n\t\t\t\t\t\"name\": \"Cats\"\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\t\"queries\": {\r\n\t\t\t\t\"s=cat\": {\r\n\t\t\t\t\t\"itemIds\": [ 1, 2 ],\r\n\t\t\t\t\t\"requestingPageByPerPage\": {}\r\n\t\t\t\t},\r\n\t\t\t\t\"s=cats\": {\r\n\t\t\t\t\t\"itemIds\": [ 2 ],\r\n\t\t\t\t\t\"requestingPageByPerPage\": {}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\n__Testing instructions:__\r\n\r\nThis should only impact the Categories block, which is the sole consumer of categories data. Verify that there are no regressions in the display of categories block, including the \"Loading\" placeholder and ultimately the display of categories.\r\n\r\nEnsure unit tests pass:\r\n\r\n```\r\nnpm test\r\n```"},"comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments/396540644","html_url":"https://github.com/WordPress/gutenberg/pull/6395#issuecomment-396540644","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/6395","id":396540644,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjU0MDY0NA==","user":{"login":"youknowriad","id":272444,"node_id":"MDQ6VXNlcjI3MjQ0NA==","avatar_url":"https://avatars3.githubusercontent.com/u/272444?v=4","gravatar_id":"","url":"https://api.github.com/users/youknowriad","html_url":"https://github.com/youknowriad","followers_url":"https://api.github.com/users/youknowriad/followers","following_url":"https://api.github.com/users/youknowriad/following{/other_user}","gists_url":"https://api.github.com/users/youknowriad/gists{/gist_id}","starred_url":"https://api.github.com/users/youknowriad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youknowriad/subscriptions","organizations_url":"https://api.github.com/users/youknowriad/orgs","repos_url":"https://api.github.com/users/youknowriad/repos","events_url":"https://api.github.com/users/youknowriad/events{/privacy}","received_events_url":"https://api.github.com/users/youknowriad/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T10:19:19Z","updated_at":"2018-06-12T10:19:19Z","author_association":"CONTRIBUTOR","body":"@aduth Hey Andrew, do you plan to revisit this one? That's one of the missing pieces to drop our current `withAPIData` usage."}}
{"actor":{"display_login":"youknowriad"}}