Skip to content

Commit

Permalink
refactor 400 error
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed May 8, 2024
1 parent 29b988a commit 65a3bd1
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 72 deletions.
8 changes: 5 additions & 3 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ struct UserText {
static let syncPausedAlertTitle = NSLocalizedString("alert.sync-paused-title", value: "Sync is Paused", comment: "Title for alert shown when sync paused for an error")
static let syncInvalidLoginAlertDescription = NSLocalizedString("alert.sync-invalid-login-error-description", value: "Sync encountered an error. Please disable sync and reconnect using your recovery code.", comment: "Description for alert shown when sync error occurs because of invalid login credentials")
static let syncTooManyRequestsAlertDescription = NSLocalizedString("alert.sync-too-many-requests-error-description", value: "Sync & Backup is temporarily unavailable.", comment: "Description for alert shown when sync error occurs because of too many requests")
static let syncBadRequestAlertDescription = NSLocalizedString("alert.sync-bad-data-error-description", value: "Some bookmarks or passwords are formatted incorrectly or too long and were not synced.", comment: "Description for alert shown when sync error occurs because of bad data")
static let syncBookmarksBadRequestAlertDescription = NSLocalizedString("alert.sync-bookmarks-bad-data-error-description", value: "Some bookmarks are formatted incorrectly or too long and were not synced.", comment: "Description for alert shown when sync error occurs because of bad data")
static let syncCredentialsBadRequestAlertDescription = NSLocalizedString("alert.sync-credentials-bad-data-error-description", value: "Some passwords are formatted incorrectly or too long and were not synced.", comment: "Description for alert shown when sync error occurs because of bad data")
static let syncErrorAlertAction = NSLocalizedString("alert.sync-error-action", value: "Sync Settings", comment: "Sync error alert action button title, takes the user to the sync settings page.")

// Sync Errors
Expand All @@ -582,8 +583,9 @@ struct UserText {
static let bookmarksLimitExceededDescription = NSLocalizedString("prefrences.sync.bookmarks-limit-exceeded-description", value: "You've reached the maximum number of bookmarks. Please delete some to resume sync.", comment: "Description for sync bookmarks limits exceeded warning")
static let credentialsLimitExceededDescription = NSLocalizedString("prefrences.sync.credentials-limit-exceeded-description", value: "You've reached the maximum number of passwords. Please delete some to resume sync.", comment: "Description for sync credentials limits exceeded warning")
static let invalidLoginCredentialErrorDescription = NSLocalizedString("prefrences.sync.invalid-login-description", value: "Sync encountered an error. Try disabling sync on this device and then reconnect using another device or your recovery code.", comment: "Description invalid credentials error when syncing.")
static let tooManyRequestsErrorDescription = NSLocalizedString("prefrences.sync.invalid-login-description", value: "Sync & Backup is temporarily unavailable.", comment: "Description of too many requests error when syncing.")
static let badRequestErrorDescription = NSLocalizedString("prefrences.sync.invalid-login-description", value: "Some bookmarks or passwords are formatted incorrectly or too long and were not synced.", comment: "Description of incorrectly formatted data error when syncing.")
static let tooManyRequestsErrorDescription = NSLocalizedString("prefrences.sync.bookmarks.too-many-requests", value: "Sync & Backup is temporarily unavailable.", comment: "Description of too many requests error when syncing.")
static let syncBookmarksBadRequestErrorDescription = NSLocalizedString("prefrences.sync.bad.request.description", value: "Some bookmarks are formatted incorrectly or too long and were not synced.", comment: "Description of incorrectly formatted data error when syncing.")
static let syncCredentialsBadRequestErrorDescription = NSLocalizedString("prefrences.sync.credentials.bad.request.description", value: "Some passwords are formatted incorrectly or too long and were not synced.", comment: "Description of incorrectly formatted data error when syncing.")
static let bookmarksLimitExceededAction = NSLocalizedString("prefrences.sync.bookmarks-limit-exceeded-action", value: "Manage Bookmarks", comment: "Button title for sync bookmarks limits exceeded warning to go to manage bookmarks")
static let credentialsLimitExceededAction = NSLocalizedString("prefrences.sync.credentials-limit-exceeded-action", value: "Manage passwords…", comment: "Button title for sync credentials limits exceeded warning to go to manage passwords")

Expand Down
64 changes: 62 additions & 2 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@
},
"alert.sync-bad-data-error-description" : {
"comment" : "Description for alert shown when sync error occurs because of bad data",
"extractionState" : "extracted_with_value",
"extractionState" : "stale",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down Expand Up @@ -1359,6 +1359,18 @@
}
}
},
"alert.sync-bookmarks-bad-data-error-description" : {
"comment" : "Description for alert shown when sync error occurs because of bad data",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Some bookmarks are formatted incorrectly or too long and were not synced."
}
}
}
},
"alert.sync-bookmarks-paused-description" : {
"comment" : "Description for alert shown when sync bookmarks paused for too many items",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -1479,6 +1491,18 @@
}
}
},
"alert.sync-credentials-bad-data-error-description" : {
"comment" : "Description for alert shown when sync error occurs because of bad data",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Some passwords are formatted incorrectly or too long and were not synced."
}
}
}
},
"alert.sync-credentials-paused-description" : {
"comment" : "Description for alert shown when sync credentials paused for too many items",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -45987,6 +46011,18 @@
}
}
},
"prefrences.sync.bad.request.description" : {
"comment" : "Description of incorrectly formatted data error when syncing.",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Some bookmarks are formatted incorrectly or too long and were not synced."
}
}
}
},
"prefrences.sync.bookmarks-limit-exceeded-action" : {
"comment" : "Button title for sync bookmarks limits exceeded warning to go to manage bookmarks",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -46107,6 +46143,18 @@
}
}
},
"prefrences.sync.bookmarks.too-many-requests" : {
"comment" : "Description of too many requests error when syncing.",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Sync & Backup is temporarily unavailable."
}
}
}
},
"prefrences.sync.credentials-limit-exceeded-action" : {
"comment" : "Button title for sync credentials limits exceeded warning to go to manage passwords",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -46227,8 +46275,20 @@
}
}
},
"prefrences.sync.credentials.bad.request.description" : {
"comment" : "Description of incorrectly formatted data error when syncing.",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Some passwords are formatted incorrectly or too long and were not synced."
}
}
}
},
"prefrences.sync.invalid-login-description" : {
"comment" : "Description invalid credentials error when syncing.\n Description of incorrectly formatted data error when syncing.\n Description of too many requests error when syncing.",
"comment" : "Description invalid credentials error when syncing.",
"extractionState" : "extracted_with_value",
"localizations" : {
"de" : {
Expand Down
32 changes: 16 additions & 16 deletions DuckDuckGo/Preferences/Model/SyncPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protocol SyncPausedStateManaging: ObservableObject {
var isSyncCredentialsPaused: Bool { get }
var syncPausedChangedPublisher: AnyPublisher<Void, Never> { get }
var syncPausedMetadata: SyncPausedMessageData? { get }
var syncBookmarksPausedMetadata: SyncPausedMessageData { get }
var syncCredentialsPausedMetadata: SyncPausedMessageData { get }
var syncBookmarksPausedMetadata: SyncPausedMessageData? { get }
var syncCredentialsPausedMetadata: SyncPausedMessageData? { get }

func syncDidTurnOff()
}
Expand Down Expand Up @@ -68,36 +68,36 @@ final class SyncPreferences: ObservableObject, SyncUI.ManagementViewModel {
return syncPreferencesErrorHandler.syncPausedMetadata?.action
}

var syncBookmarksPausedTitle: String {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata.title
var syncBookmarksPausedTitle: String? {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata?.title
}

var syncBookmarksPausedMessage: String {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata.description
var syncBookmarksPausedMessage: String? {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata?.description
}

var syncBookmarksPausedButtonTitle: String {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata.buttonTitle
var syncBookmarksPausedButtonTitle: String? {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata?.buttonTitle
}

var syncBookmarksPausedButtonAction: (() -> Void)? {
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata.action
return syncPreferencesErrorHandler.syncBookmarksPausedMetadata?.action
}

var syncCredentialsPausedTitle: String {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata.title
var syncCredentialsPausedTitle: String? {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata?.title
}

var syncCredentialsPausedMessage: String {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata.description
var syncCredentialsPausedMessage: String? {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata?.description
}

var syncCredentialsPausedButtonTitle: String {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata.buttonTitle
var syncCredentialsPausedButtonTitle: String? {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata?.buttonTitle
}

var syncCredentialsPausedButtonAction: (() -> Void)? {
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata.action
return syncPreferencesErrorHandler.syncCredentialsPausedMetadata?.action
}

struct Consts {
Expand Down
Loading

0 comments on commit 65a3bd1

Please sign in to comment.