diff --git a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m index f3dc94472..ba8d4be58 100644 --- a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m +++ b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m @@ -118,7 +118,8 @@ NS_ASSUME_NONNULL_BEGIN for (TSGroupModel *blockedGroup in blockedGroups) { 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 itemWithCustomCellBlock:^{ diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 95b91a4be..a0c52b8b4 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -248,8 +248,8 @@ /* 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."; -/* Action sheet title when confirming you want to unblock a group. Embeds the {{conversation title}}. */ -"BLOCK_LIST_UNBLOCK_GROUP_TITLE_FORMAT" = "Unblock This Group?"; +/* Action sheet title when confirming you want to unblock a group. */ +"BLOCK_LIST_UNBLOCK_GROUP_TITLE" = "Unblock This Group?"; /* A format for the 'unblock conversation' action sheet title. Embeds the {{conversation title}}. */ "BLOCK_LIST_UNBLOCK_TITLE_FORMAT" = "Unblock %@?"; diff --git a/SignalMessaging/utils/BlockListUIUtils.m b/SignalMessaging/utils/BlockListUIUtils.m index d53072c37..f1649e6ab 100644 --- a/SignalMessaging/utils/BlockListUIUtils.m +++ b/SignalMessaging/utils/BlockListUIUtils.m @@ -154,10 +154,11 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); OWSAssert(fromViewController); OWSAssert(blockingManager); + NSString *groupName = groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName; NSString *title = [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_BLOCK_GROUP_TITLE_FORMAT", @"A format for the 'block group' action sheet title. Embeds the {{group name}}."), - [self formatDisplayNameForAlertTitle:groupThread.name]]; + [self formatDisplayNameForAlertTitle:groupName]]; UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:title @@ -246,6 +247,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); DDLogError(@"Failed to leave blocked group with error: %@", error); } + NSString *groupName + = groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName; + [self showOkAlertWithTitle:NSLocalizedString(@"BLOCK_LIST_VIEW_BLOCKED_GROUP_ALERT_TITLE", @"The title of the 'group blocked' alert.") @@ -256,7 +260,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); @"The message format of the 'conversation blocked' " @"alert. " @"Embeds the {{conversation title}}."), - [self formatDisplayNameForAlertMessage:groupThread.name]] + [self formatDisplayNameForAlertMessage:groupName]] fromViewController:fromViewController completionBlock:completionBlock]; }]; @@ -279,8 +283,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); completionBlock:completionBlock]; } else if ([thread isKindOfClass:[TSGroupThread class]]) { TSGroupThread *groupThread = (TSGroupThread *)thread; + NSString *groupName = groupThread.name.length > 0 ? groupThread.name : TSGroupThread.defaultGroupName; [self showUnblockGroupActionSheet:groupThread.groupModel - displayName:groupThread.name + displayName:groupName fromViewController:fromViewController blockingManager:blockingManager completionBlock:completionBlock]; @@ -398,11 +403,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); OWSAssert(fromViewController); OWSAssert(blockingManager); - NSString *title = [NSString - stringWithFormat: - NSLocalizedString(@"BLOCK_LIST_UNBLOCK_GROUP_TITLE_FORMAT", - @"Action sheet title when confirming you want to unblock a group. Embeds the {{conversation title}}."), - [self formatDisplayNameForAlertTitle:displayName]]; + NSString *title = + [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_GROUP_TITLE", + @"Action sheet title when confirming you want to unblock a group.")]; NSString *message = NSLocalizedString( @"BLOCK_LIST_UNBLOCK_GROUP_BODY", @"Action sheet body when confirming you want to unblock a group"); diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index 37e1f1e4c..c0ff40e8b 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -221,8 +221,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(presentingViewController); OWSAssert(messageSender); + NSString *groupName = thread.name.length > 0 ? thread.name : TSGroupThread.defaultGroupName; 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 alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert]; [presentingViewController presentViewController:removingFromGroup animated:YES completion:nil]; diff --git a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m index 80732c3dd..e71224c68 100644 --- a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m +++ b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m @@ -175,6 +175,10 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific - (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; }