{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/73263180","id":73263180,"diff_hunk":"@@ -0,0 +1,110 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+import Foundation\n+import Sync\n+import XCGLogger\n+import Deferred\n+import Shared\n+import Storage\n+\n+public enum SyncDisplayState {\n+    case InProgress\n+    case Good\n+    case Bad(message: String?)\n+    case Stale(message: String)\n+\n+    func asObject() -> [String: String]? {\n+        switch self {\n+        case .Bad(let msg):\n+            guard let message = msg else {\n+                return [\"state\": \"Error\"]\n+            }\n+            return [\"state\": \"Error\",\n+                    \"message\": message]\n+        case .Stale(let message):\n+            return [\"state\": \"Warning\",\n+                    \"message\": message]\n+        default:\n+            break\n+        }\n+        return nil\n+    }\n+}\n+\n+public func ==(a: SyncDisplayState, b: SyncDisplayState) -> Bool {\n+    switch (a, b) {\n+    case (.InProgress,   .InProgress): return true\n+    case (.Good,   .Good): return true\n+    case (.Bad(let a), .Bad(let b)) where a == b: return true\n+    case (.Stale(let a), .Stale(let b)) where a == b: return true\n+    default: return false\n+    }\n+}\n+\n+private let log = Logger.syncLogger\n+\n+public struct SyncStatusResolver {\n+    let engineResults: Maybe<EngineResults>\n+\n+    public func resolveResults() -> SyncDisplayState {\n+        guard let results = engineResults.successValue else {\n+            switch engineResults.failureValue {\n+            case _ as BookmarksMergeError, _ as BookmarksDatabaseError:\n+                return SyncDisplayState.Stale(message: String(format: Strings.FirefoxSyncPartialTitle, Strings.localizedStringForSyncComponent(\"bookmarks\") ?? \"\"))\n+            default:\n+                return SyncDisplayState.Bad(message: nil)\n+            }\n+        }\n+\n+        // Run through the engine results and produce a relevant display status for each one\n+        let displayStates: [SyncDisplayState] = results.map { (engineIdentifier, syncStatus) in\n+            log.debug(\"Sync status for \\(engineIdentifier): \\(syncStatus)\")\n+\n+            switch syncStatus {\n+            case .NotStarted(let reason):\n+                switch reason {\n+\n+                // Potentially problematic reasons for not starting. Should surface to the user.\n+                case .Offline:\n+                    return .Bad(message: Strings.FirefoxSyncOfflineTitle)\n+                case .NoAccount:\n+                    // Should this ever happen? Why would we sync with no account?\n+                    return .Stale(message: Strings.FirefoxSyncOfflineTitle)\n+                default:\n+                    return .Good\n+                }\n+            default:","path":"Providers/SyncStatusResolver.swift","position":78,"original_position":78,"commit_id":"f0e52c98adb71b2d2ab03711d0bb51066698a963","original_commit_id":"f0e52c98adb71b2d2ab03711d0bb51066698a963","user":{"login":"rnewman","id":91722,"avatar_url":"https://avatars.githubusercontent.com/u/91722?v=3","gravatar_id":"","url":"https://api.github.com/users/rnewman","html_url":"https://github.com/rnewman","followers_url":"https://api.github.com/users/rnewman/followers","following_url":"https://api.github.com/users/rnewman/following{/other_user}","gists_url":"https://api.github.com/users/rnewman/gists{/gist_id}","starred_url":"https://api.github.com/users/rnewman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnewman/subscriptions","organizations_url":"https://api.github.com/users/rnewman/orgs","repos_url":"https://api.github.com/users/rnewman/repos","events_url":"https://api.github.com/users/rnewman/events{/privacy}","received_events_url":"https://api.github.com/users/rnewman/received_events","type":"User","site_admin":false},"body":"I would rather see a verbose listing of every case. One of the strengths of Swift's enums is that the compiler will warn you if you missed a case… but it can't do that if you fall back to `default`. If we add more statuses, we'll want that help.","created_at":"2016-08-03T00:31:05Z","updated_at":"2016-08-03T00:31:05Z","html_url":"https://github.com/mozilla/firefox-ios/pull/2023#discussion_r73263180","pull_request_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023","_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/73263180"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/2023#discussion_r73263180"},"pull_request":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023","id":79368843,"html_url":"https://github.com/mozilla/firefox-ios/pull/2023","diff_url":"https://github.com/mozilla/firefox-ios/pull/2023.diff","patch_url":"https://github.com/mozilla/firefox-ios/pull/2023.patch","issue_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/2023","number":2023,"state":"open","locked":false,"title":"Bug 1290331 - Removed incorrect and confusing .NotStarted sync warning messaging","user":{"login":"sleroux","id":434322,"avatar_url":"https://avatars.githubusercontent.com/u/434322?v=3","gravatar_id":"","url":"https://api.github.com/users/sleroux","html_url":"https://github.com/sleroux","followers_url":"https://api.github.com/users/sleroux/followers","following_url":"https://api.github.com/users/sleroux/following{/other_user}","gists_url":"https://api.github.com/users/sleroux/gists{/gist_id}","starred_url":"https://api.github.com/users/sleroux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleroux/subscriptions","organizations_url":"https://api.github.com/users/sleroux/orgs","repos_url":"https://api.github.com/users/sleroux/repos","events_url":"https://api.github.com/users/sleroux/events{/privacy}","received_events_url":"https://api.github.com/users/sleroux/received_events","type":"User","site_admin":false},"body":"When the sync operations complete, we are erroneously interpreting .NotStarted sync results caused by users disabling a particular sync option (tabs, history, etc) as 'Sync is unavailable'. Related, in the case the user is offline, we show the message 'Sync is offline'. The first case is not correct and we should reporting a good sync. In the second, the messaging is unclear. Are the sync servers offline? I think the messaging can be improved here. In the meantime, I propose we remove both checks until we improve the messaging/UI around reporting sync errors.","created_at":"2016-07-29T14:33:10Z","updated_at":"2016-08-03T00:31:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8aadf6728b976d24e1a26307593dc6b4e5e25637","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023/commits","review_comments_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023/comments","review_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/2023/comments","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/f0e52c98adb71b2d2ab03711d0bb51066698a963","head":{"label":"mozilla:sleroux/Bug1290331-RemoveNotStartedSyncMessaging","ref":"sleroux/Bug1290331-RemoveNotStartedSyncMessaging","sha":"f0e52c98adb71b2d2ab03711d0bb51066698a963","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/firefox-ios/deployments","created_at":"2014-11-03T19:07:02Z","updated_at":"2016-08-02T18:47:19Z","pushed_at":"2016-08-02T23:12:32Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":282155,"stargazers_count":5862,"watchers_count":5862,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1174,"mirror_url":null,"open_issues_count":53,"forks":1174,"open_issues":53,"watchers":5862,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"4f04495360381f602bc66c755f3ed3a8865ec78c","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/firefox-ios/deployments","created_at":"2014-11-03T19:07:02Z","updated_at":"2016-08-02T18:47:19Z","pushed_at":"2016-08-02T23:12:32Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":282155,"stargazers_count":5862,"watchers_count":5862,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1174,"mirror_url":null,"open_issues_count":53,"forks":1174,"open_issues":53,"watchers":5862,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/2023"},"issue":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/2023"},"comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/2023/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/2023/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/firefox-ios/statuses/f0e52c98adb71b2d2ab03711d0bb51066698a963"}}}}
{"actor":{"display_login":"rnewman"}}