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.
This commit is contained in:
Evan Hahn 2022-06-08 09:58:49 -05:00 committed by Evan Hahn
parent 3724492cb0
commit 3925b1fa0c
4 changed files with 15 additions and 9 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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.";