BlockList vs. "zero length" group names

pull/1/head
Michael Kirk 7 years ago
parent b447e68597
commit df67e883f3

@ -118,7 +118,8 @@ NS_ASSUME_NONNULL_BEGIN
for (TSGroupModel *blockedGroup in blockedGroups) { for (TSGroupModel *blockedGroup in blockedGroups) {
UIImage *image = blockedGroup.groupImage ?: OWSGroupAvatarBuilder.defaultGroupImage; UIImage *image = blockedGroup.groupImage ?: OWSGroupAvatarBuilder.defaultGroupImage;
NSString *groupName = blockedGroup.groupName ?: TSGroupThread.defaultGroupName; NSString *groupName
= blockedGroup.groupName.length > 0 ? blockedGroup.groupName : TSGroupThread.defaultGroupName;
[blockedGroupsSection addItem:[OWSTableItem [blockedGroupsSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{

@ -248,8 +248,8 @@
/* Action sheet body when confirming you want to unblock a group */ /* Action sheet body when confirming you want to unblock a group */
"BLOCK_LIST_UNBLOCK_GROUP_BODY" = "Existing members will be able to add you to the group again."; "BLOCK_LIST_UNBLOCK_GROUP_BODY" = "Existing members will be able to add you to the group again.";
/* Action sheet title when confirming you want to unblock a group. Embeds the {{conversation title}}. */ /* Action sheet title when confirming you want to unblock a group. */
"BLOCK_LIST_UNBLOCK_GROUP_TITLE_FORMAT" = "Unblock This Group?"; "BLOCK_LIST_UNBLOCK_GROUP_TITLE" = "Unblock This Group?";
/* A format for the 'unblock conversation' action sheet title. Embeds the {{conversation title}}. */ /* A format for the 'unblock conversation' action sheet title. Embeds the {{conversation title}}. */
"BLOCK_LIST_UNBLOCK_TITLE_FORMAT" = "Unblock %@?"; "BLOCK_LIST_UNBLOCK_TITLE_FORMAT" = "Unblock %@?";

@ -154,10 +154,11 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
OWSAssert(fromViewController); OWSAssert(fromViewController);
OWSAssert(blockingManager); OWSAssert(blockingManager);
NSString *groupName = groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName;
NSString *title = [NSString NSString *title = [NSString
stringWithFormat:NSLocalizedString(@"BLOCK_LIST_BLOCK_GROUP_TITLE_FORMAT", stringWithFormat:NSLocalizedString(@"BLOCK_LIST_BLOCK_GROUP_TITLE_FORMAT",
@"A format for the 'block group' action sheet title. Embeds the {{group name}}."), @"A format for the 'block group' action sheet title. Embeds the {{group name}}."),
[self formatDisplayNameForAlertTitle:groupThread.name]]; [self formatDisplayNameForAlertTitle:groupName]];
UIAlertController *actionSheetController = UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:title [UIAlertController alertControllerWithTitle:title
@ -246,6 +247,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
DDLogError(@"Failed to leave blocked group with error: %@", error); DDLogError(@"Failed to leave blocked group with error: %@", error);
} }
NSString *groupName
= groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName;
[self [self
showOkAlertWithTitle:NSLocalizedString(@"BLOCK_LIST_VIEW_BLOCKED_GROUP_ALERT_TITLE", showOkAlertWithTitle:NSLocalizedString(@"BLOCK_LIST_VIEW_BLOCKED_GROUP_ALERT_TITLE",
@"The title of the 'group blocked' alert.") @"The title of the 'group blocked' alert.")
@ -256,7 +260,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
@"The message format of the 'conversation blocked' " @"The message format of the 'conversation blocked' "
@"alert. " @"alert. "
@"Embeds the {{conversation title}}."), @"Embeds the {{conversation title}}."),
[self formatDisplayNameForAlertMessage:groupThread.name]] [self formatDisplayNameForAlertMessage:groupName]]
fromViewController:fromViewController fromViewController:fromViewController
completionBlock:completionBlock]; completionBlock:completionBlock];
}]; }];
@ -279,8 +283,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
completionBlock:completionBlock]; completionBlock:completionBlock];
} else if ([thread isKindOfClass:[TSGroupThread class]]) { } else if ([thread isKindOfClass:[TSGroupThread class]]) {
TSGroupThread *groupThread = (TSGroupThread *)thread; TSGroupThread *groupThread = (TSGroupThread *)thread;
NSString *groupName = groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName;
[self showUnblockGroupActionSheet:groupThread.groupModel [self showUnblockGroupActionSheet:groupThread.groupModel
displayName:groupThread.name displayName:groupName
fromViewController:fromViewController fromViewController:fromViewController
blockingManager:blockingManager blockingManager:blockingManager
completionBlock:completionBlock]; completionBlock:completionBlock];
@ -398,11 +403,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
OWSAssert(fromViewController); OWSAssert(fromViewController);
OWSAssert(blockingManager); OWSAssert(blockingManager);
NSString *title = [NSString NSString *title =
stringWithFormat: [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_GROUP_TITLE",
NSLocalizedString(@"BLOCK_LIST_UNBLOCK_GROUP_TITLE_FORMAT", @"Action sheet title when confirming you want to unblock a group.")];
@"Action sheet title when confirming you want to unblock a group. Embeds the {{conversation title}}."),
[self formatDisplayNameForAlertTitle:displayName]];
NSString *message = NSLocalizedString( NSString *message = NSLocalizedString(
@"BLOCK_LIST_UNBLOCK_GROUP_BODY", @"Action sheet body when confirming you want to unblock a group"); @"BLOCK_LIST_UNBLOCK_GROUP_BODY", @"Action sheet body when confirming you want to unblock a group");

@ -221,8 +221,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(presentingViewController); OWSAssert(presentingViewController);
OWSAssert(messageSender); OWSAssert(messageSender);
NSString *groupName = thread.name.length > 0 ? thread.name : TSGroupThread.defaultGroupName;
NSString *title = [NSString NSString *title = [NSString
stringWithFormat:NSLocalizedString(@"GROUP_REMOVING", @"Modal text when removing a group"), thread.name]; stringWithFormat:NSLocalizedString(@"GROUP_REMOVING", @"Modal text when removing a group"), groupName];
UIAlertController *removingFromGroup = UIAlertController *removingFromGroup =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert]; [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
[presentingViewController presentViewController:removingFromGroup animated:YES completion:nil]; [presentingViewController presentViewController:removingFromGroup animated:YES completion:nil];

@ -175,6 +175,10 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
- (NSString *)name - (NSString *)name
{ {
// TODO sometimes groupName is set to the empty string. I'm hesitent to change
// the semantics here until we have time to thouroughly test the fallout.
// Instead, see the `groupNameOrDefault` which is appropriate for use when displaying
// text corresponding to a group.
return self.groupModel.groupName ?: self.class.defaultGroupName; return self.groupModel.groupName ?: self.class.defaultGroupName;
} }

Loading…
Cancel
Save