{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6306","repository_url":"https://api.github.com/repos/Automattic/wp-calypso","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6306/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6306/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6306/events","html_url":"https://github.com/Automattic/wp-calypso/pull/6306","id":162209440,"number":6306,"title":"CPT / State: Display trash notice after save request completes successfully","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},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Custom%20Post%20Types%20(CPT)","name":"Custom Post Types (CPT)","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/State","name":"State","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-06-24T18:58:22Z","updated_at":"2016-07-01T17:29:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6306","html_url":"https://github.com/Automattic/wp-calypso/pull/6306","diff_url":"https://github.com/Automattic/wp-calypso/pull/6306.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/6306.patch"},"body":"This pull request seeks to explore one option for displaying a notice in response to a successful network request to save a post. It also seeks to refactor notices state to better accommodate this use-case and to adhere to guidelines adopted since its original implementation (e.g. action type verb suffixing).\r\n\r\n![trash](https://cloud.githubusercontent.com/assets/1779930/16347105/ee1d3674-3a18-11e6-957e-078aa8d5ecb7.gif)\r\n\r\n__Implementation notes:__\r\n\r\nI considered a few options for implementing notices:\r\n\r\n- Dispatch `successNotice` in the promise resolution of `savePost`\r\n  - Pros:\r\n    - Colocation to related actions leading to notice creation\r\n    - Notices shown even if navigating away from screen\r\n  - Cons:\r\n    - Difficult to differentiate user interaction from background process where notice may be undesirable (maybe options argument?)\r\n    - Doesn't seem possible to track notice state like count (i.e. \"2 posts trashed\")\r\n- Track success and failure in a separate reducer specific to posts, which components monitor and dispatch notice when `componentWillReceiveProps` reveals that a success or failure has occurred\r\n  - Pros:\r\n    - Feels most pure in terms of one-way-data-flow\r\n    - If \"notices shown after navigating away\" is argued to be a bad thing, then this is most obvious path to achieving the opposite effect\r\n  - Cons:\r\n    - Notice won't be shown if user navigates away (or component is otherwise unmounted)\r\n    - Seems difficult to implement correctly, and likely more code to do so than other solutions\r\n- [As implemented here, ] Monitor actions from the notices reducer\r\n  - Pros: \r\n    - If considering action types as global, appropriate for notices reducer to \"watch\" for actions which should cause a notice to be shown\r\n    - All behaviors related to notices mostly within a single file\r\n    - Notices shown even if navigating away from screen\r\n  - Cons:\r\n    - Splits action creator invoking the save from notices behavior (maybe a pro?)\r\n    - Should notices reducer concern itself with actions from other parts of state? (seems an argument against actions as being global)\r\n\r\n__Testing instructions:__\r\n\r\nEnsure Mocha tests pass:\r\n\r\n```\r\nnpm run test-client\r\n```\r\n\r\nVerify that no regressions occurred in refactorings to expected behavior for [global notices](http://calypso.localhost:3000/devdocs/design/global-notices).\r\n\r\nVerify that on the [custom post types listing screen](http://calypso.localhost:3000/types/post), when trashing a post, a notice is shown if it completes successfully. Verify also that if trashing a second post while a notice is currently visible, the text will change to reflect \"X posts\" trashed.\r\n\r\n/cc @artpi @gwwar @timmyc \n\nTest live: https://calypso.live/?branch=add/cpt-trash-notice"},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/230004008","html_url":"https://github.com/Automattic/wp-calypso/pull/6306#issuecomment-230004008","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6306","id":230004008,"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},"created_at":"2016-07-01T17:29:38Z","updated_at":"2016-07-01T17:29:38Z","body":"Thanks for the pointer @artpi , I hadn't seen that pull request. Looks like some good effort going on there, though not sure it necessarily solves the problem I'm trying to address (notices in response to asynchronous network requests). I do see that it touches on notices behavior in Reader in response to updated props, which is a bit like option 2 I had considered in the original comment."}}
{"actor":{"display_login":"aduth"}}