{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/comments/242679708","pull_request_review_id":186232415,"id":242679708,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MjY3OTcwOA==","diff_hunk":"@@ -63,29 +62,61 @@ class FirefoxAccountsIntegration(\n     override val coroutineContext: CoroutineContext\n         get() = Dispatchers.Main + job + exceptionHandler\n \n-    lateinit var account: Deferred<FirefoxAccount>\n+    lateinit var account: FirefoxAccount\n \n-    var profile: Profile? = null\n+    @Volatile var profile: Profile? = null\n         private set\n \n     @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)\n     fun init() {\n         job = Job()\n+        account = initAccount()\n+    }\n \n-        account = async {\n-            getAuthenticatedAccount()?.let {\n-                profile = it.getProfile(true).await()\n-                return@async it\n+    private fun initAccount(): FirefoxAccount {","path":"app/src/main/java/org/mozilla/reference/browser/browser/FirefoxAccountsIntegration.kt","position":49,"original_position":49,"commit_id":"7bb3d78cc77c4ac001e61b905054ec9f9bb30d80","original_commit_id":"7bb3d78cc77c4ac001e61b905054ec9f9bb30d80","user":{"login":"grigoryk","id":465422,"node_id":"MDQ6VXNlcjQ2NTQyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/465422?v=4","gravatar_id":"","url":"https://api.github.com/users/grigoryk","html_url":"https://github.com/grigoryk","followers_url":"https://api.github.com/users/grigoryk/followers","following_url":"https://api.github.com/users/grigoryk/following{/other_user}","gists_url":"https://api.github.com/users/grigoryk/gists{/gist_id}","starred_url":"https://api.github.com/users/grigoryk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grigoryk/subscriptions","organizations_url":"https://api.github.com/users/grigoryk/orgs","repos_url":"https://api.github.com/users/grigoryk/repos","events_url":"https://api.github.com/users/grigoryk/events{/privacy}","received_events_url":"https://api.github.com/users/grigoryk/received_events","type":"User","site_admin":false},"body":"I think we should separate dealing with account from dealing with profile, otherwise we're mixing two different concepts together.\r\n\r\nWe can have an good account state without ever fetching a profile, and everything should generally function (e.g. sync will work, UI should degrade to something sensible - if it doesn't, that's a bug, etc).\r\n\r\nIn other words, profile presence isn't tied to a well-functioning account. If the profile server has an outage (or if we hit a network intermittent while talking to it), that shouldn't affect things negatively.\r\n\r\nThis mixing also makes code pretty confusing to read and inefficient. In authenticate, we read an account state (json dump) from disc, and initialize a FirefoxAccount object (which goes through JSON state parsing, state upgrade, etc path on the Rust side). Then, if we don't have a profile for some reason by the time we hit `authenticate`, we do all of this _again_!\r\n\r\nIn other words, we should only ever hit the expensive `authenticate` path if we don't have a valid account state. Currently, `SettingsFragment` checks for `profile` presence, which is wrong.","created_at":"2018-12-18T19:45:10Z","updated_at":"2018-12-18T19:49:05Z","html_url":"https://github.com/mozilla-mobile/reference-browser/pull/343#discussion_r242679708","pull_request_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/comments/242679708"},"html":{"href":"https://github.com/mozilla-mobile/reference-browser/pull/343#discussion_r242679708"},"pull_request":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343","id":239579539,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5NTc5NTM5","html_url":"https://github.com/mozilla-mobile/reference-browser/pull/343","diff_url":"https://github.com/mozilla-mobile/reference-browser/pull/343.diff","patch_url":"https://github.com/mozilla-mobile/reference-browser/pull/343.patch","issue_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/343","number":343,"state":"open","locked":false,"title":"Closes #336: FxA sign in does not open tab when app started offline","user":{"login":"csadilek","id":472523,"node_id":"MDQ6VXNlcjQ3MjUyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/472523?v=4","gravatar_id":"","url":"https://api.github.com/users/csadilek","html_url":"https://github.com/csadilek","followers_url":"https://api.github.com/users/csadilek/followers","following_url":"https://api.github.com/users/csadilek/following{/other_user}","gists_url":"https://api.github.com/users/csadilek/gists{/gist_id}","starred_url":"https://api.github.com/users/csadilek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csadilek/subscriptions","organizations_url":"https://api.github.com/users/csadilek/orgs","repos_url":"https://api.github.com/users/csadilek/repos","events_url":"https://api.github.com/users/csadilek/events{/privacy}","received_events_url":"https://api.github.com/users/csadilek/received_events","type":"User","site_admin":false},"body":"This is now allowing us to recover from network failures during initialization and previous authentication attempts. We now also make sure we show an error to the user if they try to authenticate without a network connection (a tab is displayed similar to fennec.)\r\n\r\nIn addition, I've simplified this a bit and removed a few `await` calls as `account` no longer needs to be a `Deferred`.","created_at":"2018-12-18T17:56:57Z","updated_at":"2018-12-18T19:49:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb73975ede8628d1a53513af11d429194532ad27","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343/commits","review_comments_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343/comments","review_comment_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/343/comments","statuses_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/statuses/7bb3d78cc77c4ac001e61b905054ec9f9bb30d80","head":{"label":"csadilek:issue-336","ref":"issue-336","sha":"7bb3d78cc77c4ac001e61b905054ec9f9bb30d80","user":{"login":"csadilek","id":472523,"node_id":"MDQ6VXNlcjQ3MjUyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/472523?v=4","gravatar_id":"","url":"https://api.github.com/users/csadilek","html_url":"https://github.com/csadilek","followers_url":"https://api.github.com/users/csadilek/followers","following_url":"https://api.github.com/users/csadilek/following{/other_user}","gists_url":"https://api.github.com/users/csadilek/gists{/gist_id}","starred_url":"https://api.github.com/users/csadilek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csadilek/subscriptions","organizations_url":"https://api.github.com/users/csadilek/orgs","repos_url":"https://api.github.com/users/csadilek/repos","events_url":"https://api.github.com/users/csadilek/events{/privacy}","received_events_url":"https://api.github.com/users/csadilek/received_events","type":"User","site_admin":false},"repo":{"id":151302669,"node_id":"MDEwOlJlcG9zaXRvcnkxNTEzMDI2Njk=","name":"reference-browser","full_name":"csadilek/reference-browser","private":false,"owner":{"login":"csadilek","id":472523,"node_id":"MDQ6VXNlcjQ3MjUyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/472523?v=4","gravatar_id":"","url":"https://api.github.com/users/csadilek","html_url":"https://github.com/csadilek","followers_url":"https://api.github.com/users/csadilek/followers","following_url":"https://api.github.com/users/csadilek/following{/other_user}","gists_url":"https://api.github.com/users/csadilek/gists{/gist_id}","starred_url":"https://api.github.com/users/csadilek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csadilek/subscriptions","organizations_url":"https://api.github.com/users/csadilek/orgs","repos_url":"https://api.github.com/users/csadilek/repos","events_url":"https://api.github.com/users/csadilek/events{/privacy}","received_events_url":"https://api.github.com/users/csadilek/received_events","type":"User","site_admin":false},"html_url":"https://github.com/csadilek/reference-browser","description":"A reference browser implementation using Mozilla Android Components","fork":true,"url":"https://api.github.com/repos/csadilek/reference-browser","forks_url":"https://api.github.com/repos/csadilek/reference-browser/forks","keys_url":"https://api.github.com/repos/csadilek/reference-browser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/csadilek/reference-browser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/csadilek/reference-browser/teams","hooks_url":"https://api.github.com/repos/csadilek/reference-browser/hooks","issue_events_url":"https://api.github.com/repos/csadilek/reference-browser/issues/events{/number}","events_url":"https://api.github.com/repos/csadilek/reference-browser/events","assignees_url":"https://api.github.com/repos/csadilek/reference-browser/assignees{/user}","branches_url":"https://api.github.com/repos/csadilek/reference-browser/branches{/branch}","tags_url":"https://api.github.com/repos/csadilek/reference-browser/tags","blobs_url":"https://api.github.com/repos/csadilek/reference-browser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/csadilek/reference-browser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/csadilek/reference-browser/git/refs{/sha}","trees_url":"https://api.github.com/repos/csadilek/reference-browser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/csadilek/reference-browser/statuses/{sha}","languages_url":"https://api.github.com/repos/csadilek/reference-browser/languages","stargazers_url":"https://api.github.com/repos/csadilek/reference-browser/stargazers","contributors_url":"https://api.github.com/repos/csadilek/reference-browser/contributors","subscribers_url":"https://api.github.com/repos/csadilek/reference-browser/subscribers","subscription_url":"https://api.github.com/repos/csadilek/reference-browser/subscription","commits_url":"https://api.github.com/repos/csadilek/reference-browser/commits{/sha}","git_commits_url":"https://api.github.com/repos/csadilek/reference-browser/git/commits{/sha}","comments_url":"https://api.github.com/repos/csadilek/reference-browser/comments{/number}","issue_comment_url":"https://api.github.com/repos/csadilek/reference-browser/issues/comments{/number}","contents_url":"https://api.github.com/repos/csadilek/reference-browser/contents/{+path}","compare_url":"https://api.github.com/repos/csadilek/reference-browser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/csadilek/reference-browser/merges","archive_url":"https://api.github.com/repos/csadilek/reference-browser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/csadilek/reference-browser/downloads","issues_url":"https://api.github.com/repos/csadilek/reference-browser/issues{/number}","pulls_url":"https://api.github.com/repos/csadilek/reference-browser/pulls{/number}","milestones_url":"https://api.github.com/repos/csadilek/reference-browser/milestones{/number}","notifications_url":"https://api.github.com/repos/csadilek/reference-browser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/csadilek/reference-browser/labels{/name}","releases_url":"https://api.github.com/repos/csadilek/reference-browser/releases{/id}","deployments_url":"https://api.github.com/repos/csadilek/reference-browser/deployments","created_at":"2018-10-02T18:23:59Z","updated_at":"2018-10-02T18:24:01Z","pushed_at":"2018-12-18T19:05:53Z","git_url":"git://github.com/csadilek/reference-browser.git","ssh_url":"git@github.com:csadilek/reference-browser.git","clone_url":"https://github.com/csadilek/reference-browser.git","svn_url":"https://github.com/csadilek/reference-browser","homepage":null,"size":1267,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0","node_id":"MDc6TGljZW5zZTE0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-mobile:master","ref":"master","sha":"c46b8bc6a8a89f263e4e47399b01fcda1f5e3764","user":{"login":"mozilla-mobile","id":22351667,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzUxNjY3","avatar_url":"https://avatars3.githubusercontent.com/u/22351667?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-mobile","html_url":"https://github.com/mozilla-mobile","followers_url":"https://api.github.com/users/mozilla-mobile/followers","following_url":"https://api.github.com/users/mozilla-mobile/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-mobile/subscriptions","organizations_url":"https://api.github.com/users/mozilla-mobile/orgs","repos_url":"https://api.github.com/users/mozilla-mobile/repos","events_url":"https://api.github.com/users/mozilla-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":151247213,"node_id":"MDEwOlJlcG9zaXRvcnkxNTEyNDcyMTM=","name":"reference-browser","full_name":"mozilla-mobile/reference-browser","private":false,"owner":{"login":"mozilla-mobile","id":22351667,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzUxNjY3","avatar_url":"https://avatars3.githubusercontent.com/u/22351667?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-mobile","html_url":"https://github.com/mozilla-mobile","followers_url":"https://api.github.com/users/mozilla-mobile/followers","following_url":"https://api.github.com/users/mozilla-mobile/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-mobile/subscriptions","organizations_url":"https://api.github.com/users/mozilla-mobile/orgs","repos_url":"https://api.github.com/users/mozilla-mobile/repos","events_url":"https://api.github.com/users/mozilla-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-mobile/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mozilla-mobile/reference-browser","description":"A full-featured browser reference implementation using Mozilla Android Components.","fork":false,"url":"https://api.github.com/repos/mozilla-mobile/reference-browser","forks_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/forks","keys_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/teams","hooks_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/hooks","issue_events_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/events","assignees_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/tags","blobs_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/languages","stargazers_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/stargazers","contributors_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/contributors","subscribers_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/subscribers","subscription_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/subscription","commits_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/merges","archive_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/downloads","issues_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-mobile/reference-browser/deployments","created_at":"2018-10-02T12:00:13Z","updated_at":"2018-12-18T19:36:59Z","pushed_at":"2018-12-18T19:36:57Z","git_url":"git://github.com/mozilla-mobile/reference-browser.git","ssh_url":"git@github.com:mozilla-mobile/reference-browser.git","clone_url":"https://github.com/mozilla-mobile/reference-browser.git","svn_url":"https://github.com/mozilla-mobile/reference-browser","homepage":"","size":1266,"stargazers_count":51,"watchers_count":51,"language":"Kotlin","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":21,"mirror_url":null,"archived":false,"open_issues_count":228,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0","node_id":"MDc6TGljZW5zZTE0"},"forks":21,"open_issues":228,"watchers":51,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343"},"html":{"href":"https://github.com/mozilla-mobile/reference-browser/pull/343"},"issue":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/343"},"comments":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/issues/343/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/pulls/343/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-mobile/reference-browser/statuses/7bb3d78cc77c4ac001e61b905054ec9f9bb30d80"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"grigoryk"}}