diff --git a/Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift b/Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift index d59decdd445..5bd353bd6ad 100644 --- a/Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift +++ b/Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift @@ -369,31 +369,37 @@ extension SyncWelcomeViewController: SyncPairControllerDelegate { case .safe: self.enableDefaultTypeAndPushSettings() case .approvalNeeded: - let namesDevicesSyncChain = fetchNamesOfDevicesInSyncChain() + let devicesSyncChain = fetchNamesOfDevicesInSyncChain() // Showing and alert with device list; if user answers no - leave chain, if yes - enable the bookmarks type var alertMessage = "" - if !namesDevicesSyncChain.isEmpty { - alertMessage += "\(Strings.Sync.syncDevicesInSyncChainTitle):" - - for name in namesDevicesSyncChain where !name.isEmpty { - alertMessage += "\n\(name)" + if !devicesSyncChain.isEmpty { + for device in devicesSyncChain where !device.name.isEmpty { + if device.isCurrentDevice { + var currentDeviceNameList = "\n\(device.name) (\(Strings.syncThisDevice))" + currentDeviceNameList += alertMessage + alertMessage = currentDeviceNameList + } else { + alertMessage += "\n\(device.name)" + } } + + alertMessage = "\n\(Strings.Sync.syncDevicesInSyncChainTitle):\n" + alertMessage } alertMessage += "\n\n \(Strings.Sync.syncJoinChainCodewordsWarning)" let alert = UIAlertController( - title: Strings.syncJoinChainWarningTitle, + title: Strings.Sync.syncJoinChainWarningTitle, message: alertMessage, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: Strings.yes, style: .default) { _ in - self.enableDefaultTypeAndPushSettings() - }) - alert.addAction(UIAlertAction(title: Strings.no, style: .default) { _ in + alert.addAction(UIAlertAction(title: Strings.cancelButtonTitle, style: .default) { _ in self.leaveIncompleteSyncChain() }) + alert.addAction(UIAlertAction(title: Strings.confirm, style: .default) { _ in + self.enableDefaultTypeAndPushSettings() + }) present(alert, animated: true, completion: nil) case .blocked: // Devices 10 and more - add alert to block and prevent sync @@ -448,7 +454,7 @@ extension SyncWelcomeViewController: SyncPairControllerDelegate { return (deviceLimitLevel, nil) } - private func fetchNamesOfDevicesInSyncChain() -> [String] { + private func fetchNamesOfDevicesInSyncChain() -> [(name: String, isCurrentDevice: Bool)] { let deviceListJSON = syncAPI.getDeviceListJSON() let deviceList = fetchSyncDeviceList(listJSON: deviceListJSON) @@ -460,7 +466,7 @@ extension SyncWelcomeViewController: SyncPairControllerDelegate { return [] } - return devices.map { $0.name ?? "" } + return devices.map { ($0.name ?? "", $0.isCurrentDevice) } } private func fetchSyncDeviceList(listJSON: String?) -> (devices: [BraveSyncDevice]?, error: DeviceRetriavalError?) { diff --git a/Sources/BraveStrings/BraveStrings.swift b/Sources/BraveStrings/BraveStrings.swift index b532b3d6f0a..a6f0fcb64f3 100644 --- a/Sources/BraveStrings/BraveStrings.swift +++ b/Sources/BraveStrings/BraveStrings.swift @@ -988,7 +988,6 @@ extension Strings { public static let syncRemoveOtherDeviceTitle = NSLocalizedString("SyncRemoveOtherDeviceTitle", tableName: "BraveShared", bundle: .module, value: "Remove %@ from Sync Chain?", comment: "Title for removing other device from Sync") public static let syncRemoveOtherDeviceMessage = NSLocalizedString("SyncRemoveOtherDeviceMessage", tableName: "BraveShared", bundle: .module, value: "Removing the device from the Sync Chain will not clear previously synced data from the device.", comment: "Message for removing other device from Sync") public static let syncRemoveDeviceDefaultName = NSLocalizedString("SyncRemoveDeviceDefaultName", tableName: "BraveShared", bundle: .module, value: "Device", comment: "Default name for a device") - public static let syncJoinChainWarningTitle = NSLocalizedString("syncJoinChainWarningTitle", tableName: "BraveShared", bundle: .module, value: "Warning", comment: "Title for pairing sync device") public static let syncValidForTooLongError = NSLocalizedString("syncValidForTooLongError", tableName: "BraveShared", bundle: .module, value: "This code is invalid. Please check that the time and timezone are set correctly on your device.", comment: "Sync Error Description") public static let syncDeprecatedVersionError = NSLocalizedString("syncDeprecatedVersionError", tableName: "BraveShared", bundle: .module, value: "This sync code was generated by an outdated version of Brave on another device. Please update Brave on all synced devices and try again.", comment: "Sync Error Description") public static let syncExpiredError = NSLocalizedString("syncExpiredError", tableName: "BraveShared", bundle: .module, value: "This sync code has expired, please generate a new sync code and try again.", comment: "Sync Error message for when the sync code is expired") @@ -3263,46 +3262,53 @@ extension Strings { comment: "The title displayed in alert when a user needs to set passcode") public static let syncSetPasscodeAlertDescription = NSLocalizedString( - "login.syncSetPasscodeAlertDescription", + "sync.syncSetPasscodeAlertDescription", tableName: "BraveShared", bundle: .module, value: "To add a device to sync chain or toggle password sync, you must first set a passcode on your device.", comment: "The message displayed in alert when a user needs to set a passcode") public static let syncJoinChainCodewordsWarning = NSLocalizedString( - "syncJoinChainCodewordsWarning", + "sync.syncJoinChainCodewordsWarning", tableName: "BraveShared", bundle: .module, value: "Note: You should verify you recognize each device in the list above. Devices in a sync chain may receive personal data like passwords and browsing history.", comment: "A warning when user adds more than 5 device to sync chain") public static let syncDeviceFetchErrorAlertDescription = NSLocalizedString( - "login.syncDeviceFetchErrorAlertDescription", + "sync.syncDeviceFetchErrorAlertDescription", tableName: "BraveShared", bundle: .module, value: "Something went wrong while retrieving devices in sync chain.", comment: "The message displayed in alert when a there is a problem with fetching devices") public static let syncDevicesInSyncChainTitle = NSLocalizedString( - "login.syncDevicesInSyncChainTitle", + "sync.syncDevicesInSyncChainTitle", tableName: "BraveShared", bundle: .module, value: "Devices in Sync Chain", comment: "The message displayed in alert when a list of devices will be shown") public static let syncMaximumDeviceReachedErrorTitle = NSLocalizedString( - "login.syncMaximumDeviceReachedErrorTitle", + "sync.syncMaximumDeviceReachedErrorTitle", tableName: "BraveShared", bundle: .module, value: "Device limit", comment: "The warning displayed in alert when the maxmium of devices is reached") public static let syncMaximumDeviceReachedErrorDescription = NSLocalizedString( - "login.syncMaximumDeviceReachedErrorDescription", + "sync.syncMaximumDeviceReachedErrorDescription", tableName: "BraveShared", bundle: .module, value: "You've reached the maximum number of devices (10) allowed in a sync chain. Remove a device to continue.", comment: "The message displayed in alert when the maxmium of devices is reached") + public static let syncJoinChainWarningTitle = + NSLocalizedString( + "sync.syncJoinChainWarningTitle", + tableName: "BraveShared", + bundle: .module, + value: "Device Confirmation", + comment: "Title for alert error for device confirmation") } }