{"action":"created","comment":{"url":"https://api.github.com/repos/hypothesis/client/pulls/comments/78932458","id":78932458,"diff_hunk":"@@ -119,12 +143,17 @@ function RootThread($rootScope, annotationUI, features, searchFilter, viewFilter\n     $rootScope.$on(event, function (event, annotation) {\n       var annotations = [].concat(annotation);\n \n+      if (event.name === events.BEFORE_ANNOTATION_CREATED) {","path":"h/static/scripts/root-thread.js","position":51,"original_position":51,"commit_id":"fcf041768ca53f85729802fc80de1615eba67adf","original_commit_id":"fcf041768ca53f85729802fc80de1615eba67adf","user":{"login":"nickstenning","id":3602,"avatar_url":"https://avatars.githubusercontent.com/u/3602?v=3","gravatar_id":"","url":"https://api.github.com/users/nickstenning","html_url":"https://github.com/nickstenning","followers_url":"https://api.github.com/users/nickstenning/followers","following_url":"https://api.github.com/users/nickstenning/following{/other_user}","gists_url":"https://api.github.com/users/nickstenning/gists{/gist_id}","starred_url":"https://api.github.com/users/nickstenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickstenning/subscriptions","organizations_url":"https://api.github.com/users/nickstenning/orgs","repos_url":"https://api.github.com/users/nickstenning/repos","events_url":"https://api.github.com/users/nickstenning/events{/privacy}","received_events_url":"https://api.github.com/users/nickstenning/received_events","type":"User","site_admin":false},"body":"We now have two different conditionals in here that check if `event.name === events.BEFORE_ANNOTATION_CREATED`. I think it would make more sense for this event to have a different handler function at this point.","created_at":"2016-09-15T10:24:56Z","updated_at":"2016-09-15T10:24:56Z","html_url":"https://github.com/hypothesis/client/pull/107#discussion_r78932458","pull_request_url":"https://api.github.com/repos/hypothesis/client/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/hypothesis/client/pulls/comments/78932458"},"html":{"href":"https://github.com/hypothesis/client/pull/107#discussion_r78932458"},"pull_request":{"href":"https://api.github.com/repos/hypothesis/client/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/hypothesis/client/pulls/107","id":85361251,"html_url":"https://github.com/hypothesis/client/pull/107","diff_url":"https://github.com/hypothesis/client/pull/107.diff","patch_url":"https://github.com/hypothesis/client/pull/107.patch","issue_url":"https://api.github.com/repos/hypothesis/client/issues/107","number":107,"state":"open","locked":false,"title":"Fix off-screen empty drafts not being removed when a new annotation is created","user":{"login":"robertknight","id":2458,"avatar_url":"https://avatars.githubusercontent.com/u/2458?v=3","gravatar_id":"","url":"https://api.github.com/users/robertknight","html_url":"https://github.com/robertknight","followers_url":"https://api.github.com/users/robertknight/followers","following_url":"https://api.github.com/users/robertknight/following{/other_user}","gists_url":"https://api.github.com/users/robertknight/gists{/gist_id}","starred_url":"https://api.github.com/users/robertknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertknight/subscriptions","organizations_url":"https://api.github.com/users/robertknight/orgs","repos_url":"https://api.github.com/users/robertknight/repos","events_url":"https://api.github.com/users/robertknight/events{/privacy}","received_events_url":"https://api.github.com/users/robertknight/received_events","type":"User","site_admin":false},"body":"The logic to remove new and empty annotations used to live in the\r\n`<annotation>` component because that was the only part of the code that\r\nhad access to the state of unsaved changes.\r\n\r\nSince `<annotation>` instances are only created for on-screen annotations,\r\nthis can result in empty drafts not being removed if the empty\r\nannotation is off-screen.\r\n\r\nNow that the canonical content of unsaved annotations is stored in the\r\ndrafts service, we can move the logic outside of the annotation\r\ncomponent and fix this problem.\r\n\r\nAs with https://github.com/hypothesis/client/pull/106, drafts should live in the app state which would make implementing this kind of logic very easy, but that is blocked on other refactoring. This PR at least fixes the issue and documents (via tests) the intended behavior.\r\n\r\nFixes #97","created_at":"2016-09-15T08:12:02Z","updated_at":"2016-09-15T10:27:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b672b8b2267e71b7ab35bea44f123a0296b6de9b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hypothesis/client/pulls/107/commits","review_comments_url":"https://api.github.com/repos/hypothesis/client/pulls/107/comments","review_comment_url":"https://api.github.com/repos/hypothesis/client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hypothesis/client/issues/107/comments","statuses_url":"https://api.github.com/repos/hypothesis/client/statuses/fcf041768ca53f85729802fc80de1615eba67adf","head":{"label":"hypothesis:fix-offscreen-draft-removal","ref":"fix-offscreen-draft-removal","sha":"fcf041768ca53f85729802fc80de1615eba67adf","user":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"repo":{"id":62234930,"name":"client","full_name":"hypothesis/client","owner":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hypothesis/client","description":"The Hypothesis web-based annotation client.","fork":false,"url":"https://api.github.com/repos/hypothesis/client","forks_url":"https://api.github.com/repos/hypothesis/client/forks","keys_url":"https://api.github.com/repos/hypothesis/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hypothesis/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hypothesis/client/teams","hooks_url":"https://api.github.com/repos/hypothesis/client/hooks","issue_events_url":"https://api.github.com/repos/hypothesis/client/issues/events{/number}","events_url":"https://api.github.com/repos/hypothesis/client/events","assignees_url":"https://api.github.com/repos/hypothesis/client/assignees{/user}","branches_url":"https://api.github.com/repos/hypothesis/client/branches{/branch}","tags_url":"https://api.github.com/repos/hypothesis/client/tags","blobs_url":"https://api.github.com/repos/hypothesis/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hypothesis/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hypothesis/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/hypothesis/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hypothesis/client/statuses/{sha}","languages_url":"https://api.github.com/repos/hypothesis/client/languages","stargazers_url":"https://api.github.com/repos/hypothesis/client/stargazers","contributors_url":"https://api.github.com/repos/hypothesis/client/contributors","subscribers_url":"https://api.github.com/repos/hypothesis/client/subscribers","subscription_url":"https://api.github.com/repos/hypothesis/client/subscription","commits_url":"https://api.github.com/repos/hypothesis/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/hypothesis/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/hypothesis/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/hypothesis/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/hypothesis/client/contents/{+path}","compare_url":"https://api.github.com/repos/hypothesis/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hypothesis/client/merges","archive_url":"https://api.github.com/repos/hypothesis/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hypothesis/client/downloads","issues_url":"https://api.github.com/repos/hypothesis/client/issues{/number}","pulls_url":"https://api.github.com/repos/hypothesis/client/pulls{/number}","milestones_url":"https://api.github.com/repos/hypothesis/client/milestones{/number}","notifications_url":"https://api.github.com/repos/hypothesis/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hypothesis/client/labels{/name}","releases_url":"https://api.github.com/repos/hypothesis/client/releases{/id}","deployments_url":"https://api.github.com/repos/hypothesis/client/deployments","created_at":"2016-06-29T15:02:29Z","updated_at":"2016-09-12T15:49:01Z","pushed_at":"2016-09-15T10:19:28Z","git_url":"git://github.com/hypothesis/client.git","ssh_url":"git@github.com:hypothesis/client.git","clone_url":"https://github.com/hypothesis/client.git","svn_url":"https://github.com/hypothesis/client","homepage":null,"size":13738,"stargazers_count":16,"watchers_count":16,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":26,"forks":8,"open_issues":26,"watchers":16,"default_branch":"master"}},"base":{"label":"hypothesis:master","ref":"master","sha":"71e95f591a43c8fb3a8bdb06b7d29230bd8ef0d0","user":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"repo":{"id":62234930,"name":"client","full_name":"hypothesis/client","owner":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hypothesis/client","description":"The Hypothesis web-based annotation client.","fork":false,"url":"https://api.github.com/repos/hypothesis/client","forks_url":"https://api.github.com/repos/hypothesis/client/forks","keys_url":"https://api.github.com/repos/hypothesis/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hypothesis/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hypothesis/client/teams","hooks_url":"https://api.github.com/repos/hypothesis/client/hooks","issue_events_url":"https://api.github.com/repos/hypothesis/client/issues/events{/number}","events_url":"https://api.github.com/repos/hypothesis/client/events","assignees_url":"https://api.github.com/repos/hypothesis/client/assignees{/user}","branches_url":"https://api.github.com/repos/hypothesis/client/branches{/branch}","tags_url":"https://api.github.com/repos/hypothesis/client/tags","blobs_url":"https://api.github.com/repos/hypothesis/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hypothesis/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hypothesis/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/hypothesis/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hypothesis/client/statuses/{sha}","languages_url":"https://api.github.com/repos/hypothesis/client/languages","stargazers_url":"https://api.github.com/repos/hypothesis/client/stargazers","contributors_url":"https://api.github.com/repos/hypothesis/client/contributors","subscribers_url":"https://api.github.com/repos/hypothesis/client/subscribers","subscription_url":"https://api.github.com/repos/hypothesis/client/subscription","commits_url":"https://api.github.com/repos/hypothesis/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/hypothesis/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/hypothesis/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/hypothesis/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/hypothesis/client/contents/{+path}","compare_url":"https://api.github.com/repos/hypothesis/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hypothesis/client/merges","archive_url":"https://api.github.com/repos/hypothesis/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hypothesis/client/downloads","issues_url":"https://api.github.com/repos/hypothesis/client/issues{/number}","pulls_url":"https://api.github.com/repos/hypothesis/client/pulls{/number}","milestones_url":"https://api.github.com/repos/hypothesis/client/milestones{/number}","notifications_url":"https://api.github.com/repos/hypothesis/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hypothesis/client/labels{/name}","releases_url":"https://api.github.com/repos/hypothesis/client/releases{/id}","deployments_url":"https://api.github.com/repos/hypothesis/client/deployments","created_at":"2016-06-29T15:02:29Z","updated_at":"2016-09-12T15:49:01Z","pushed_at":"2016-09-15T10:19:28Z","git_url":"git://github.com/hypothesis/client.git","ssh_url":"git@github.com:hypothesis/client.git","clone_url":"https://github.com/hypothesis/client.git","svn_url":"https://github.com/hypothesis/client","homepage":null,"size":13738,"stargazers_count":16,"watchers_count":16,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":26,"forks":8,"open_issues":26,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hypothesis/client/pulls/107"},"html":{"href":"https://github.com/hypothesis/client/pull/107"},"issue":{"href":"https://api.github.com/repos/hypothesis/client/issues/107"},"comments":{"href":"https://api.github.com/repos/hypothesis/client/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/hypothesis/client/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/hypothesis/client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hypothesis/client/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/hypothesis/client/statuses/fcf041768ca53f85729802fc80de1615eba67adf"}}}}
{"actor":{"display_login":"nickstenning"}}