{"action":"created","comment":{"url":"https://api.github.com/repos/yued-fe/y-translation/pulls/comments/209860323","pull_request_review_id":145934101,"id":209860323,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTg2MDMyMw==","diff_hunk":"@@ -116,41 +101,22 @@ analytics could look like this:\n       event.waitUntil(promiseChain);\n     });\n \n-Here we are calling a function that returns a promise `pushReceivedTracking()`,\n-which, for the sake of the example, we can pretend will make a network request\n-to our analytics provider. We are also making a network request, getting the\n-response and showing a notification using the responses data for the title and\n-message of the notification.\n-\n-We can ensure the service worker is kept alive while both of these tasks are done by combining\n-these promises with `Promise.all()`. The resulting promise is passed into `event.waitUntil()`\n-meaning the browser will wait until both promises have finished before checking that a notification\n-has been displayed and terminating the service worker.\n-\n-Note: If you ever find your promise chains confusing or a little messy,\n-I find that breaking things into functions helps to reduce complexity.\n-I'd also recommend\n-[this blog post by Philip Walton on untangling promise\n-chains](https://philipwalton.com/articles/untangling-deeply-nested-promise-chains/).\n-The main point to take away is that you should experiment with how promises can be written\n-and chained to find a style that works for you.\n-\n-The reason we should be concerned about `waitUntil()` and how to use it is that one of the most\n-common issues developers face is that when the promise chain is incorrect / broken, Chrome will\n-show this \"default\" notification:\n+\n+这里为了示例，我们调用一个返回 promise 对象的函数`pushReceivedTracking()`，\n+，假装将发出网络请求到我们的分析提供商。同时，我们也会发送网络请求、获取响应，并使用响应的数据来显示通知的标题和内容。\n+\n+我们使用`Promise.all()`将这两个 promise 对象合并，来确保 service worker 在这两个任务完成之前存活。合并后的 promise 被传递进`event.waitUntil()`，这意味着浏览器将等到两个 promise 都完成后，才会检查通知已显示，最后终止 service worker。\n+\n+注意：如果你对 promise 链式调用有些疑惑，将功能分解为函数会有助于降低复杂性，同时也推荐这篇[Philip Walton 的博文](https://philipwalton.com/articles/untangling-deeply-nested-promise-chains/)l来理解 promise 的链式调用。重点是你应该尝试如何来写 promise 以及它的链式调用，最终找到适合自己的风格。\n+\n+我们应该关注 `waitUntil()`以及如何使用它，因为开发人员常常会面临的一个问题是，当 promise 链使用的不正确时，Chrome会\n+显示此“默认”通知：\n \n ![An Image of the default notification in Chrome](./images/default-notification-mobile.png)\n \n-Chrome will only show the \"This site has been updated in the background.\" notification when a\n-push message is received and the push event in the service worker **does not** show a\n-notification after the promise passed to `event.waitUntil()` has finished.\n+当接收到一个推送消息，但在 service worker 中的推送事件当传递给`event.waitUntil()`的 promise 结束之后也没有显示任何消息，Chrome 就只会显示 \"This site has been updated in the background.\" ","path":"todo/push-notifications/handling-messages.md","position":163,"original_position":163,"commit_id":"0cbe2e6884ecd53c07e4e48cc2288daee09d0410","original_commit_id":"0cbe2e6884ecd53c07e4e48cc2288daee09d0410","user":{"login":"HSDPA-wen","id":6448761,"node_id":"MDQ6VXNlcjY0NDg3NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/6448761?v=4","gravatar_id":"","url":"https://api.github.com/users/HSDPA-wen","html_url":"https://github.com/HSDPA-wen","followers_url":"https://api.github.com/users/HSDPA-wen/followers","following_url":"https://api.github.com/users/HSDPA-wen/following{/other_user}","gists_url":"https://api.github.com/users/HSDPA-wen/gists{/gist_id}","starred_url":"https://api.github.com/users/HSDPA-wen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSDPA-wen/subscriptions","organizations_url":"https://api.github.com/users/HSDPA-wen/orgs","repos_url":"https://api.github.com/users/HSDPA-wen/repos","events_url":"https://api.github.com/users/HSDPA-wen/events{/privacy}","received_events_url":"https://api.github.com/users/HSDPA-wen/received_events","type":"User","site_admin":false},"body":"是否可以修改成：当接收到一个推送消息，并且传递给`event.waitUntil()`中推送事件的 promise 结束后也没有显示任何消息","created_at":"2018-08-14T08:02:47Z","updated_at":"2018-08-14T08:08:19Z","html_url":"https://github.com/yued-fe/y-translation/pull/45#discussion_r209860323","pull_request_url":"https://api.github.com/repos/yued-fe/y-translation/pulls/45","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/comments/209860323"},"html":{"href":"https://github.com/yued-fe/y-translation/pull/45#discussion_r209860323"},"pull_request":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/yued-fe/y-translation/pulls/45","id":204676032,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0Njc2MDMy","html_url":"https://github.com/yued-fe/y-translation/pull/45","diff_url":"https://github.com/yued-fe/y-translation/pull/45.diff","patch_url":"https://github.com/yued-fe/y-translation/pull/45.patch","issue_url":"https://api.github.com/repos/yued-fe/y-translation/issues/45","number":45,"state":"open","locked":false,"title":"push notifications: handling messages","user":{"login":"Zhangdroid","id":6471705,"node_id":"MDQ6VXNlcjY0NzE3MDU=","avatar_url":"https://avatars3.githubusercontent.com/u/6471705?v=4","gravatar_id":"","url":"https://api.github.com/users/Zhangdroid","html_url":"https://github.com/Zhangdroid","followers_url":"https://api.github.com/users/Zhangdroid/followers","following_url":"https://api.github.com/users/Zhangdroid/following{/other_user}","gists_url":"https://api.github.com/users/Zhangdroid/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhangdroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhangdroid/subscriptions","organizations_url":"https://api.github.com/users/Zhangdroid/orgs","repos_url":"https://api.github.com/users/Zhangdroid/repos","events_url":"https://api.github.com/users/Zhangdroid/events{/privacy}","received_events_url":"https://api.github.com/users/Zhangdroid/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-30T01:53:52Z","updated_at":"2018-08-14T08:08:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13b7f2fc8128ad8df755a3fcc1f6a151300cf671","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":903593910,"node_id":"MDU6TGFiZWw5MDM1OTM5MTA=","url":"https://api.github.com/repos/yued-fe/y-translation/labels/%E4%BA%8C%E6%A0%A1%E6%AD%A3%E5%9C%A8%E6%A0%A1%E5%AF%B9","name":"二校正在校对","color":"fef2c0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/yued-fe/y-translation/pulls/45/commits","review_comments_url":"https://api.github.com/repos/yued-fe/y-translation/pulls/45/comments","review_comment_url":"https://api.github.com/repos/yued-fe/y-translation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yued-fe/y-translation/issues/45/comments","statuses_url":"https://api.github.com/repos/yued-fe/y-translation/statuses/0cbe2e6884ecd53c07e4e48cc2288daee09d0410","head":{"label":"Zhangdroid:push-notifications-handling-messages","ref":"push-notifications-handling-messages","sha":"0cbe2e6884ecd53c07e4e48cc2288daee09d0410","user":{"login":"Zhangdroid","id":6471705,"node_id":"MDQ6VXNlcjY0NzE3MDU=","avatar_url":"https://avatars3.githubusercontent.com/u/6471705?v=4","gravatar_id":"","url":"https://api.github.com/users/Zhangdroid","html_url":"https://github.com/Zhangdroid","followers_url":"https://api.github.com/users/Zhangdroid/followers","following_url":"https://api.github.com/users/Zhangdroid/following{/other_user}","gists_url":"https://api.github.com/users/Zhangdroid/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhangdroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhangdroid/subscriptions","organizations_url":"https://api.github.com/users/Zhangdroid/orgs","repos_url":"https://api.github.com/users/Zhangdroid/repos","events_url":"https://api.github.com/users/Zhangdroid/events{/privacy}","received_events_url":"https://api.github.com/users/Zhangdroid/received_events","type":"User","site_admin":false},"repo":{"id":142811023,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI4MTEwMjM=","name":"y-translation","full_name":"Zhangdroid/y-translation","owner":{"login":"Zhangdroid","id":6471705,"node_id":"MDQ6VXNlcjY0NzE3MDU=","avatar_url":"https://avatars3.githubusercontent.com/u/6471705?v=4","gravatar_id":"","url":"https://api.github.com/users/Zhangdroid","html_url":"https://github.com/Zhangdroid","followers_url":"https://api.github.com/users/Zhangdroid/followers","following_url":"https://api.github.com/users/Zhangdroid/following{/other_user}","gists_url":"https://api.github.com/users/Zhangdroid/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhangdroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhangdroid/subscriptions","organizations_url":"https://api.github.com/users/Zhangdroid/orgs","repos_url":"https://api.github.com/users/Zhangdroid/repos","events_url":"https://api.github.com/users/Zhangdroid/events{/privacy}","received_events_url":"https://api.github.com/users/Zhangdroid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zhangdroid/y-translation","description":"阅文集团前端翻译项目","fork":true,"url":"https://api.github.com/repos/Zhangdroid/y-translation","forks_url":"https://api.github.com/repos/Zhangdroid/y-translation/forks","keys_url":"https://api.github.com/repos/Zhangdroid/y-translation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zhangdroid/y-translation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zhangdroid/y-translation/teams","hooks_url":"https://api.github.com/repos/Zhangdroid/y-translation/hooks","issue_events_url":"https://api.github.com/repos/Zhangdroid/y-translation/issues/events{/number}","events_url":"https://api.github.com/repos/Zhangdroid/y-translation/events","assignees_url":"https://api.github.com/repos/Zhangdroid/y-translation/assignees{/user}","branches_url":"https://api.github.com/repos/Zhangdroid/y-translation/branches{/branch}","tags_url":"https://api.github.com/repos/Zhangdroid/y-translation/tags","blobs_url":"https://api.github.com/repos/Zhangdroid/y-translation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zhangdroid/y-translation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zhangdroid/y-translation/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zhangdroid/y-translation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zhangdroid/y-translation/statuses/{sha}","languages_url":"https://api.github.com/repos/Zhangdroid/y-translation/languages","stargazers_url":"https://api.github.com/repos/Zhangdroid/y-translation/stargazers","contributors_url":"https://api.github.com/repos/Zhangdroid/y-translation/contributors","subscribers_url":"https://api.github.com/repos/Zhangdroid/y-translation/subscribers","subscription_url":"https://api.github.com/repos/Zhangdroid/y-translation/subscription","commits_url":"https://api.github.com/repos/Zhangdroid/y-translation/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zhangdroid/y-translation/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zhangdroid/y-translation/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zhangdroid/y-translation/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zhangdroid/y-translation/contents/{+path}","compare_url":"https://api.github.com/repos/Zhangdroid/y-translation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zhangdroid/y-translation/merges","archive_url":"https://api.github.com/repos/Zhangdroid/y-translation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zhangdroid/y-translation/downloads","issues_url":"https://api.github.com/repos/Zhangdroid/y-translation/issues{/number}","pulls_url":"https://api.github.com/repos/Zhangdroid/y-translation/pulls{/number}","milestones_url":"https://api.github.com/repos/Zhangdroid/y-translation/milestones{/number}","notifications_url":"https://api.github.com/repos/Zhangdroid/y-translation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zhangdroid/y-translation/labels{/name}","releases_url":"https://api.github.com/repos/Zhangdroid/y-translation/releases{/id}","deployments_url":"https://api.github.com/repos/Zhangdroid/y-translation/deployments","created_at":"2018-07-30T01:45:09Z","updated_at":"2018-07-30T01:45:10Z","pushed_at":"2018-08-09T10:56:17Z","git_url":"git://github.com/Zhangdroid/y-translation.git","ssh_url":"git@github.com:Zhangdroid/y-translation.git","clone_url":"https://github.com/Zhangdroid/y-translation.git","svn_url":"https://github.com/Zhangdroid/y-translation","homepage":"","size":11840,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yued-fe:master","ref":"master","sha":"df5e061a6d0f4d8303a84a2efbd794e6ee30dc09","user":{"login":"yued-fe","id":16679226,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2Njc5MjI2","avatar_url":"https://avatars3.githubusercontent.com/u/16679226?v=4","gravatar_id":"","url":"https://api.github.com/users/yued-fe","html_url":"https://github.com/yued-fe","followers_url":"https://api.github.com/users/yued-fe/followers","following_url":"https://api.github.com/users/yued-fe/following{/other_user}","gists_url":"https://api.github.com/users/yued-fe/gists{/gist_id}","starred_url":"https://api.github.com/users/yued-fe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yued-fe/subscriptions","organizations_url":"https://api.github.com/users/yued-fe/orgs","repos_url":"https://api.github.com/users/yued-fe/repos","events_url":"https://api.github.com/users/yued-fe/events{/privacy}","received_events_url":"https://api.github.com/users/yued-fe/received_events","type":"Organization","site_admin":false},"repo":{"id":127707491,"node_id":"MDEwOlJlcG9zaXRvcnkxMjc3MDc0OTE=","name":"y-translation","full_name":"yued-fe/y-translation","owner":{"login":"yued-fe","id":16679226,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2Njc5MjI2","avatar_url":"https://avatars3.githubusercontent.com/u/16679226?v=4","gravatar_id":"","url":"https://api.github.com/users/yued-fe","html_url":"https://github.com/yued-fe","followers_url":"https://api.github.com/users/yued-fe/followers","following_url":"https://api.github.com/users/yued-fe/following{/other_user}","gists_url":"https://api.github.com/users/yued-fe/gists{/gist_id}","starred_url":"https://api.github.com/users/yued-fe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yued-fe/subscriptions","organizations_url":"https://api.github.com/users/yued-fe/orgs","repos_url":"https://api.github.com/users/yued-fe/repos","events_url":"https://api.github.com/users/yued-fe/events{/privacy}","received_events_url":"https://api.github.com/users/yued-fe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yued-fe/y-translation","description":"阅文集团前端翻译项目","fork":false,"url":"https://api.github.com/repos/yued-fe/y-translation","forks_url":"https://api.github.com/repos/yued-fe/y-translation/forks","keys_url":"https://api.github.com/repos/yued-fe/y-translation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yued-fe/y-translation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yued-fe/y-translation/teams","hooks_url":"https://api.github.com/repos/yued-fe/y-translation/hooks","issue_events_url":"https://api.github.com/repos/yued-fe/y-translation/issues/events{/number}","events_url":"https://api.github.com/repos/yued-fe/y-translation/events","assignees_url":"https://api.github.com/repos/yued-fe/y-translation/assignees{/user}","branches_url":"https://api.github.com/repos/yued-fe/y-translation/branches{/branch}","tags_url":"https://api.github.com/repos/yued-fe/y-translation/tags","blobs_url":"https://api.github.com/repos/yued-fe/y-translation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yued-fe/y-translation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yued-fe/y-translation/git/refs{/sha}","trees_url":"https://api.github.com/repos/yued-fe/y-translation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yued-fe/y-translation/statuses/{sha}","languages_url":"https://api.github.com/repos/yued-fe/y-translation/languages","stargazers_url":"https://api.github.com/repos/yued-fe/y-translation/stargazers","contributors_url":"https://api.github.com/repos/yued-fe/y-translation/contributors","subscribers_url":"https://api.github.com/repos/yued-fe/y-translation/subscribers","subscription_url":"https://api.github.com/repos/yued-fe/y-translation/subscription","commits_url":"https://api.github.com/repos/yued-fe/y-translation/commits{/sha}","git_commits_url":"https://api.github.com/repos/yued-fe/y-translation/git/commits{/sha}","comments_url":"https://api.github.com/repos/yued-fe/y-translation/comments{/number}","issue_comment_url":"https://api.github.com/repos/yued-fe/y-translation/issues/comments{/number}","contents_url":"https://api.github.com/repos/yued-fe/y-translation/contents/{+path}","compare_url":"https://api.github.com/repos/yued-fe/y-translation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yued-fe/y-translation/merges","archive_url":"https://api.github.com/repos/yued-fe/y-translation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yued-fe/y-translation/downloads","issues_url":"https://api.github.com/repos/yued-fe/y-translation/issues{/number}","pulls_url":"https://api.github.com/repos/yued-fe/y-translation/pulls{/number}","milestones_url":"https://api.github.com/repos/yued-fe/y-translation/milestones{/number}","notifications_url":"https://api.github.com/repos/yued-fe/y-translation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yued-fe/y-translation/labels{/name}","releases_url":"https://api.github.com/repos/yued-fe/y-translation/releases{/id}","deployments_url":"https://api.github.com/repos/yued-fe/y-translation/deployments","created_at":"2018-04-02T05:40:07Z","updated_at":"2018-08-14T06:57:33Z","pushed_at":"2018-08-14T07:00:03Z","git_url":"git://github.com/yued-fe/y-translation.git","ssh_url":"git@github.com:yued-fe/y-translation.git","clone_url":"https://github.com/yued-fe/y-translation.git","svn_url":"https://github.com/yued-fe/y-translation","homepage":"","size":11898,"stargazers_count":91,"watchers_count":91,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":30,"license":null,"forks":20,"open_issues":30,"watchers":91,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/45"},"html":{"href":"https://github.com/yued-fe/y-translation/pull/45"},"issue":{"href":"https://api.github.com/repos/yued-fe/y-translation/issues/45"},"comments":{"href":"https://api.github.com/repos/yued-fe/y-translation/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yued-fe/y-translation/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/yued-fe/y-translation/statuses/0cbe2e6884ecd53c07e4e48cc2288daee09d0410"}},"author_association":"NONE"}}
{"actor":{"display_login":"HSDPA-wen"}}