{"action":"created","comment":{"url":"https://api.github.com/repos/resin-io/etcher/pulls/comments/119240304","pull_request_review_id":41101498,"id":119240304,"diff_hunk":"@@ -42,75 +53,95 @@ class SafeWebview extends react.PureComponent {\n     super(props);\n \n     this.state = {\n-      shouldLoad: true\n+      shouldShow: true\n     };\n \n     // Events steal 'this'\n     this.didFailLoad = _.bind(this.didFailLoad, this);\n     this.didGetResponseDetails = _.bind(this.didGetResponseDetails, this);\n+\n+    // Make a persistent electron session called 'success-banner'\n+    electron.remote.session.fromPartition('persist:success-banner', {\n+\n+      // Disable the cache for the 'success-banner' session used by the webview\n+      cache: false\n+    });\n   }\n \n   /**\n    * @returns {react.Element}\n    */\n   render() {\n-    if (this.state.shouldLoad) {\n-      const url = new URL(this.props.src);\n-\n-      // We set the 'etcher-version' GET parameter here.\n-      url.searchParams.set('etcher-version', packageJSON.version);\n-\n-      return react.createElement('webview', {\n-        ref: 'webview',\n-        src: url.href\n-      }, []);\n-    }\n-\n-    // We have to return null explicitly, undefined is an error in React.\n-    return null;\n+    return react.createElement('webview', {\n+      ref: 'webview',\n+      style: {\n+        flex: this.state.shouldShow ? null : '0 1',\n+        width: this.state.shouldShow ? null : '0',\n+        height: this.state.shouldShow ? null : '0'\n+      }\n+    }, []);\n   }\n \n   /**\n-   * @summary Add the Webview events if there is an element\n+   * @summary Add the Webview events\n    */\n   componentDidMount() {\n \n-    // There is no element to add events to if 'shouldLoad' is false.\n-    if (this.state.shouldLoad) {\n+    // Events React is unaware of have to be handled manually\n+    this.refs.webview.addEventListener('did-fail-load', this.didFailLoad);\n+    this.refs.webview.addEventListener('did-get-response-details', this.didGetResponseDetails);\n+    this.refs.webview.addEventListener('new-window', this.constructor.newWindow);\n+    this.refs.webview.addEventListener('console-message', this.constructor.consoleMessage);\n \n-      // Events React is unaware of have to be handled manually\n-      this.refs.webview.addEventListener('did-fail-load', this.didFailLoad);\n-      this.refs.webview.addEventListener('did-get-response-details', this.didGetResponseDetails);\n-      this.refs.webview.addEventListener('new-window', this.constructor.newWindow);\n-      this.refs.webview.addEventListener('console-message', this.constructor.consoleMessage);\n+    // Use the 'success-banner' session\n+    this.refs.webview.partition = 'persist:success-banner';\n \n-    }\n+    // It's important that this comes after the partition setting, otherwise it will\n+    // use another session and we can't change it without destroying the element again\n+    this.refs.webview.src = this.makeURL();\n   }\n \n   /**\n-   * @summary Remove the Webview events if there is an element\n+   * @summary Refresh the webview if we are navigating away from the success page\n+   * @param {Object} nextProps - upcoming properties\n    */\n-  componentWillUnmount() {\n+  componentWillReceiveProps(nextProps) {\n+    if (nextProps.refreshNow && !this.props.refreshNow) {\n \n-    // There is no element to remove events from if 'shouldLoad' is false.\n-    if (this.state.shouldLoad) {\n+      // Reload the page if it hasn't changed, otherwise reset the source URL,\n+      // because reload interferes with 'src' setting, resetting the 'src' attribute\n+      // to what it was was just prior.\n+      if (this.refs.webview.src === this.makeURL()) {\n+        this.refs.webview.reload();\n \n-      // Events React is unaware of have to be handled manually\n-      this.refs.webview.removeEventListener('did-fail-load', this.didFailLoad);\n-      this.refs.webview.removeEventListener('did-get-response-details', this.didGetResponseDetails);\n-      this.refs.webview.removeEventListener('new-window', this.constructor.newWindow);\n-      this.refs.webview.removeEventListener('console-message', this.constructor.consoleMessage);\n+      } else {\n+        this.refs.webview.src = this.makeURL();","path":"lib/gui/components/safe-webview/safe-webview.js","position":121,"original_position":121,"commit_id":"862e52787b7173a3f5afa475b30ce00c11268088","original_commit_id":"862e52787b7173a3f5afa475b30ce00c11268088","user":{"login":"lurch","id":476186,"avatar_url":"https://avatars1.githubusercontent.com/u/476186?v=3","gravatar_id":"","url":"https://api.github.com/users/lurch","html_url":"https://github.com/lurch","followers_url":"https://api.github.com/users/lurch/followers","following_url":"https://api.github.com/users/lurch/following{/other_user}","gists_url":"https://api.github.com/users/lurch/gists{/gist_id}","starred_url":"https://api.github.com/users/lurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lurch/subscriptions","organizations_url":"https://api.github.com/users/lurch/orgs","repos_url":"https://api.github.com/users/lurch/repos","events_url":"https://api.github.com/users/lurch/events{/privacy}","received_events_url":"https://api.github.com/users/lurch/received_events","type":"User","site_admin":false},"body":"Should we assign the result of `this.makeURL()` to a const variable, to avoid calling the function multiple times?","created_at":"2017-05-30T23:29:51Z","updated_at":"2017-05-30T23:39:05Z","html_url":"https://github.com/resin-io/etcher/pull/1422#discussion_r119240304","pull_request_url":"https://api.github.com/repos/resin-io/etcher/pulls/1422","_links":{"self":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/comments/119240304"},"html":{"href":"https://github.com/resin-io/etcher/pull/1422#discussion_r119240304"},"pull_request":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/1422"}}},"pull_request":{"url":"https://api.github.com/repos/resin-io/etcher/pulls/1422","id":120351701,"html_url":"https://github.com/resin-io/etcher/pull/1422","diff_url":"https://github.com/resin-io/etcher/pull/1422.diff","patch_url":"https://github.com/resin-io/etcher/pull/1422.patch","issue_url":"https://api.github.com/repos/resin-io/etcher/issues/1422","number":1422,"state":"open","locked":false,"title":"feat(GUI): reset webview after navigating away","user":{"login":"Shou","id":819413,"avatar_url":"https://avatars2.githubusercontent.com/u/819413?v=3","gravatar_id":"","url":"https://api.github.com/users/Shou","html_url":"https://github.com/Shou","followers_url":"https://api.github.com/users/Shou/followers","following_url":"https://api.github.com/users/Shou/following{/other_user}","gists_url":"https://api.github.com/users/Shou/gists{/gist_id}","starred_url":"https://api.github.com/users/Shou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shou/subscriptions","organizations_url":"https://api.github.com/users/Shou/orgs","repos_url":"https://api.github.com/users/Shou/repos","events_url":"https://api.github.com/users/Shou/events{/privacy}","received_events_url":"https://api.github.com/users/Shou/received_events","type":"User","site_admin":false},"body":"We reload and reset the webview to its original URL when the user\r\nnavigates away from the success screen.\r\n\r\nChangelog-Entry: Reset webview after navigating away from success\r\nscreen.","created_at":"2017-05-12T15:45:11Z","updated_at":"2017-05-30T23:39:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f714c427de670fb035de1ca0e79ffc24bb768b9","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/resin-io/etcher/pulls/1422/commits","review_comments_url":"https://api.github.com/repos/resin-io/etcher/pulls/1422/comments","review_comment_url":"https://api.github.com/repos/resin-io/etcher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resin-io/etcher/issues/1422/comments","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/862e52787b7173a3f5afa475b30ce00c11268088","head":{"label":"resin-io:webview-refresh","ref":"webview-refresh","sha":"862e52787b7173a3f5afa475b30ce00c11268088","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":45055693,"name":"etcher","full_name":"resin-io/etcher","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/etcher","description":"Flash OS images to SD cards & USB drives, safely and easily.","fork":false,"url":"https://api.github.com/repos/resin-io/etcher","forks_url":"https://api.github.com/repos/resin-io/etcher/forks","keys_url":"https://api.github.com/repos/resin-io/etcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/etcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/etcher/teams","hooks_url":"https://api.github.com/repos/resin-io/etcher/hooks","issue_events_url":"https://api.github.com/repos/resin-io/etcher/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/etcher/events","assignees_url":"https://api.github.com/repos/resin-io/etcher/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/etcher/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/etcher/tags","blobs_url":"https://api.github.com/repos/resin-io/etcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/etcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/etcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/etcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/etcher/languages","stargazers_url":"https://api.github.com/repos/resin-io/etcher/stargazers","contributors_url":"https://api.github.com/repos/resin-io/etcher/contributors","subscribers_url":"https://api.github.com/repos/resin-io/etcher/subscribers","subscription_url":"https://api.github.com/repos/resin-io/etcher/subscription","commits_url":"https://api.github.com/repos/resin-io/etcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/etcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/etcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/etcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/etcher/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/etcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/etcher/merges","archive_url":"https://api.github.com/repos/resin-io/etcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/etcher/downloads","issues_url":"https://api.github.com/repos/resin-io/etcher/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/etcher/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/etcher/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/etcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/etcher/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/etcher/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/etcher/deployments","created_at":"2015-10-27T16:53:23Z","updated_at":"2017-05-30T22:05:42Z","pushed_at":"2017-05-30T18:48:47Z","git_url":"git://github.com/resin-io/etcher.git","ssh_url":"git@github.com:resin-io/etcher.git","clone_url":"https://github.com/resin-io/etcher.git","svn_url":"https://github.com/resin-io/etcher","homepage":"https://etcher.io","size":62309,"stargazers_count":3123,"watchers_count":3123,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":180,"mirror_url":null,"open_issues_count":144,"forks":180,"open_issues":144,"watchers":3123,"default_branch":"master"}},"base":{"label":"resin-io:master","ref":"master","sha":"9a3900debb5045825c4bcbd7cc9af42b4bc500be","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":45055693,"name":"etcher","full_name":"resin-io/etcher","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/etcher","description":"Flash OS images to SD cards & USB drives, safely and easily.","fork":false,"url":"https://api.github.com/repos/resin-io/etcher","forks_url":"https://api.github.com/repos/resin-io/etcher/forks","keys_url":"https://api.github.com/repos/resin-io/etcher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/etcher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/etcher/teams","hooks_url":"https://api.github.com/repos/resin-io/etcher/hooks","issue_events_url":"https://api.github.com/repos/resin-io/etcher/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/etcher/events","assignees_url":"https://api.github.com/repos/resin-io/etcher/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/etcher/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/etcher/tags","blobs_url":"https://api.github.com/repos/resin-io/etcher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/etcher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/etcher/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/etcher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/etcher/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/etcher/languages","stargazers_url":"https://api.github.com/repos/resin-io/etcher/stargazers","contributors_url":"https://api.github.com/repos/resin-io/etcher/contributors","subscribers_url":"https://api.github.com/repos/resin-io/etcher/subscribers","subscription_url":"https://api.github.com/repos/resin-io/etcher/subscription","commits_url":"https://api.github.com/repos/resin-io/etcher/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/etcher/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/etcher/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/etcher/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/etcher/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/etcher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/etcher/merges","archive_url":"https://api.github.com/repos/resin-io/etcher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/etcher/downloads","issues_url":"https://api.github.com/repos/resin-io/etcher/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/etcher/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/etcher/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/etcher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/etcher/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/etcher/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/etcher/deployments","created_at":"2015-10-27T16:53:23Z","updated_at":"2017-05-30T22:05:42Z","pushed_at":"2017-05-30T18:48:47Z","git_url":"git://github.com/resin-io/etcher.git","ssh_url":"git@github.com:resin-io/etcher.git","clone_url":"https://github.com/resin-io/etcher.git","svn_url":"https://github.com/resin-io/etcher","homepage":"https://etcher.io","size":62309,"stargazers_count":3123,"watchers_count":3123,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":180,"mirror_url":null,"open_issues_count":144,"forks":180,"open_issues":144,"watchers":3123,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/1422"},"html":{"href":"https://github.com/resin-io/etcher/pull/1422"},"issue":{"href":"https://api.github.com/repos/resin-io/etcher/issues/1422"},"comments":{"href":"https://api.github.com/repos/resin-io/etcher/issues/1422/comments"},"review_comments":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/1422/comments"},"review_comment":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resin-io/etcher/pulls/1422/commits"},"statuses":{"href":"https://api.github.com/repos/resin-io/etcher/statuses/862e52787b7173a3f5afa475b30ce00c11268088"}}}}
{"actor":{"display_login":"lurch"}}