From 3925b1fa0c3475eaacdf0abf44a48fc7a2abcc3e Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Wed, 8 Jun 2022 09:58:49 -0500 Subject: [PATCH] Better error when recipients can't get gift badges Previously, the error was a generic fallback (and a crash in development). Now, it's a proper message. --- .../BadgeGiftingChooseRecipientViewController.swift | 3 +-- .../NewGroupView/BaseGroupMemberViewController.swift | 2 +- .../RecipientPicker/RecipientPickerDelegate.swift | 12 ++++++++---- Signal/translations/en.lproj/Localizable.strings | 7 +++++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/Donations/BadgeGiftingChooseRecipientViewController.swift b/Signal/src/ViewControllers/AppSettings/Donations/BadgeGiftingChooseRecipientViewController.swift index 380da9399e..8f9bf574fe 100644 --- a/Signal/src/ViewControllers/AppSettings/Donations/BadgeGiftingChooseRecipientViewController.swift +++ b/Signal/src/ViewControllers/AppSettings/Donations/BadgeGiftingChooseRecipientViewController.swift @@ -84,8 +84,7 @@ extension BadgeGiftingChooseRecipientViewController: RecipientPickerDelegate { case .invalidRecipient: return .unknownError case .cannotReceiveGifts: - // TODO (GB): Return a better error here. - return .unknownError + return .userLacksGiftBadgeCapability case .canReceiveGifts: return .canBeSelected } diff --git a/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift b/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift index 191f8fb0b5..256673d1d8 100644 --- a/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift +++ b/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift @@ -358,7 +358,7 @@ extension BaseGroupMemberViewController: RecipientPickerDelegate { // Re-fetch profile for this user. ProfileFetcherJob.fetchProfile(address: address, ignoreThrottling: true) - return .memberHasOutdatedClient + return .userLacksGroupCapability } return .canBeSelected } diff --git a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift index 1fd5f904b1..ac13910b8d 100644 --- a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift +++ b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift @@ -10,7 +10,8 @@ public enum RecipientPickerRecipientState: Int { case duplicateGroupMember case userAlreadyInBlocklist case conversationAlreadyInBlocklist - case memberHasOutdatedClient + case userLacksGroupCapability + case userLacksGiftBadgeCapability case unknownError } @@ -165,9 +166,12 @@ extension RecipientPickerViewController { owsFailDebug("Unexpected value.") errorMessage = NSLocalizedString("RECIPIENT_PICKER_ERROR_USER_CANNOT_BE_SELECTED", comment: "Error message indicating that a user can't be selected.") - case .memberHasOutdatedClient: - errorMessage = NSLocalizedString("RECIPIENT_PICKER_ERROR_USER_HAS_OUTDATED_CLIENT", - comment: "Error message indicating that a user can't be selected until they upgrade their app.") + case .userLacksGroupCapability: + errorMessage = NSLocalizedString("RECIPIENT_PICKER_ERROR_CANNOT_ADD_TO_GROUP_BECAUSE_USER_HAS_OUTDATED_CLIENT", + comment: "Error message indicating that a user can't be added to a group until they upgrade their app.") + case .userLacksGiftBadgeCapability: + errorMessage = NSLocalizedString("RECIPIENT_PICKER_ERROR_USER_CANNOT_RECEIVE_GIFT_BADGES", + comment: "Error message indicating that a user can't receive gifts.") } OWSActionSheets.showErrorAlert(message: errorMessage) return diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 38e39ee18d..ce6b2f5e21 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -4585,11 +4585,14 @@ /* Pressing this button marks a thread as read */ "READ_ACTION" = "Read"; +/* Error message indicating that a user can't be added to a group until they upgrade their app. */ +"RECIPIENT_PICKER_ERROR_CANNOT_ADD_TO_GROUP_BECAUSE_USER_HAS_OUTDATED_CLIENT" = "This user can't be added to the group until they upgrade Signal."; + /* Error message indicating that a user can't be selected. */ "RECIPIENT_PICKER_ERROR_USER_CANNOT_BE_SELECTED" = "User can't be selected."; -/* Error message indicating that a user can't be selected until they upgrade their app. */ -"RECIPIENT_PICKER_ERROR_USER_HAS_OUTDATED_CLIENT" = "This user can't be added to the group until they upgrade Signal."; +/* Error message indicating that a user can't receive gifts. */ +"RECIPIENT_PICKER_ERROR_USER_CANNOT_RECEIVE_GIFT_BADGES" = "This user can't receive gifts until they upgrade Signal."; /* Label for 'I forgot my PIN' link in the 2FA registration view. */ "REGISTER_2FA_FORGOT_PIN" = "I forgot my PIN.";