Skip to content

Commit a039aac

Browse files
committed
Improve UX for multiple “no longer verified” members of a group.
// FREEBIE
1 parent 509d2d0 commit a039aac

File tree

3 files changed

+89
-11
lines changed

3 files changed

+89
-11
lines changed

Signal/src/ViewControllers/ConversationView/MessagesViewController.m

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -844,19 +844,27 @@ - (void)blockBannerViewWasTapped:(UIGestureRecognizer *)sender
844844
- (void)noLongerVerifiedBannerViewWasTapped:(UIGestureRecognizer *)sender
845845
{
846846
if (sender.state == UIGestureRecognizerStateRecognized) {
847+
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
848+
if (noLongerVerifiedRecipientIds.count < 1) {
849+
return;
850+
}
851+
BOOL hasMultiple = noLongerVerifiedRecipientIds.count > 1;
852+
847853
UIAlertController *actionSheetController =
848854
[UIAlertController alertControllerWithTitle:nil
849855
message:nil
850856
preferredStyle:UIAlertControllerStyleActionSheet];
851857

852858
__weak MessagesViewController *weakSelf = self;
853859
UIAlertAction *verifyAction = [UIAlertAction
854-
actionWithTitle:
855-
NSLocalizedString(@"VERIFY_PRIVACY",
856-
@"Label for button or row which allows users to verify the safety number of another user.")
857-
style:UIAlertActionStyleDefault
860+
actionWithTitle:(hasMultiple ? NSLocalizedString(@"VERIFY_PRIVACY_MULTIPLE",
861+
@"Label for button or row which allows users to verify the safety "
862+
@"numbers of multiple users.")
863+
: NSLocalizedString(@"VERIFY_PRIVACY",
864+
@"Label for button or row which allows users to verify the safety "
865+
@"number of another user."))style:UIAlertActionStyleDefault
858866
handler:^(UIAlertAction *_Nonnull action) {
859-
[weakSelf showConversationSettingsAndShowVerification:YES];
867+
[weakSelf showNoLongerVerifiedUI];
860868
}];
861869
[actionSheetController addAction:verifyAction];
862870

@@ -1952,6 +1960,18 @@ - (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
19521960

19531961
#pragma mark - Actions
19541962

1963+
- (void)showNoLongerVerifiedUI
1964+
{
1965+
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
1966+
if (noLongerVerifiedRecipientIds.count > 1) {
1967+
[self showConversationSettingsAndShowVerification:YES];
1968+
} else if (noLongerVerifiedRecipientIds.count == 1) {
1969+
// Pick one in an arbitrary but deterministic manner.
1970+
NSString *recipientId = noLongerVerifiedRecipientIds.lastObject;
1971+
[self showFingerprintWithRecipientId:recipientId];
1972+
}
1973+
}
1974+
19551975
- (void)showConversationSettings
19561976
{
19571977
[self showConversationSettingsAndShowVerification:NO];

Signal/src/ViewControllers/ShowGroupMembersViewController.m

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,60 @@ - (void)updateTableContents
121121

122122
OWSTableContents *contents = [OWSTableContents new];
123123

124-
__weak ShowGroupMembersViewController *weakSelf = self;
125124
ContactsViewHelper *helper = self.contactsViewHelper;
126125

126+
OWSTableSection *membersSection = [OWSTableSection new];
127+
127128
// Group Members
128129

129-
OWSTableSection *section = [OWSTableSection new];
130+
// If there are "no longer verified" members of the group,
131+
// highlight them in a special section.
132+
NSSet<NSString *> *noLongerVerifiedRecipientIds = [NSSet setWithArray:[self noLongerVerifiedRecipientIds]];
133+
if (noLongerVerifiedRecipientIds.count > 0) {
134+
OWSTableSection *noLongerVerifiedSection = [OWSTableSection new];
135+
noLongerVerifiedSection.headerTitle = NSLocalizedString(@"GROUP_MEMBERS_SECTION_TITLE_NO_LONGER_VERIFIED",
136+
@"Title for the 'no longer verified' section of the 'group members' view.");
137+
membersSection.headerTitle = NSLocalizedString(
138+
@"GROUP_MEMBERS_SECTION_TITLE_MEMBERS", @"Title for the 'members' section of the 'group members' view.");
139+
[self addMembers:noLongerVerifiedRecipientIds.allObjects
140+
toSection:noLongerVerifiedSection
141+
noLongerVerifiedRecipientIds:noLongerVerifiedRecipientIds];
142+
[contents addSection:noLongerVerifiedSection];
143+
}
130144

131145
NSMutableSet *memberRecipientIds = [self.memberRecipientIds mutableCopy];
132146
[memberRecipientIds removeObject:[helper localNumber]];
133-
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
147+
[self addMembers:memberRecipientIds.allObjects
148+
toSection:membersSection
149+
noLongerVerifiedRecipientIds:noLongerVerifiedRecipientIds];
150+
[contents addSection:membersSection];
151+
152+
self.contents = contents;
153+
}
154+
155+
- (void)addMembers:(NSArray<NSString *> *)recipientIds
156+
toSection:(OWSTableSection *)section
157+
noLongerVerifiedRecipientIds:(NSSet<NSString *> *)noLongerVerifiedRecipientIds
158+
{
159+
OWSAssert(recipientIds);
160+
OWSAssert(section);
161+
OWSAssert(noLongerVerifiedRecipientIds);
162+
163+
__weak ShowGroupMembersViewController *weakSelf = self;
164+
ContactsViewHelper *helper = self.contactsViewHelper;
165+
for (NSString *recipientId in [recipientIds sortedArrayUsingSelector:@selector(compare:)]) {
134166
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
135167
ShowGroupMembersViewController *strongSelf = weakSelf;
136168
OWSAssert(strongSelf);
137169

138170
ContactTableViewCell *cell = [ContactTableViewCell new];
139171
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId];
172+
BOOL isNoLongerVerified = [noLongerVerifiedRecipientIds containsObject:recipientId];
140173
BOOL isBlocked = [helper isRecipientIdBlocked:recipientId];
141-
if (isBlocked) {
174+
if (isNoLongerVerified) {
175+
cell.accessoryMessage = NSLocalizedString(
176+
@"CONTACT_CELL_IS_NO_LONGER_VERIFIED", @"An indicator that a contact is no longer verified.");
177+
} else if (isBlocked) {
142178
cell.accessoryMessage
143179
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
144180
}
@@ -162,9 +198,19 @@ - (void)updateTableContents
162198
[weakSelf didSelectRecipientId:recipientId];
163199
}]];
164200
}
165-
[contents addSection:section];
201+
}
166202

167-
self.contents = contents;
203+
// Returns a collection of the group members who are "no longer verified".
204+
- (NSArray<NSString *> *)noLongerVerifiedRecipientIds
205+
{
206+
NSMutableArray<NSString *> *result = [NSMutableArray new];
207+
for (NSString *recipientId in self.thread.recipientIdentifiers) {
208+
if ([[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
209+
== OWSVerificationStateNoLongerVerified) {
210+
[result addObject:recipientId];
211+
}
212+
}
213+
return [result copy];
168214
}
169215

170216
- (void)didSelectRecipientId:(NSString *)recipientId

Signal/translations/en.lproj/Localizable.strings

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@
268268
/* An indicator that a contact has been blocked. */
269269
"CONTACT_CELL_IS_BLOCKED" = "Blocked";
270270

271+
/* An indicator that a contact is no longer verified. */
272+
"CONTACT_CELL_IS_NO_LONGER_VERIFIED" = "Not Verified";
273+
271274
/* No comment provided by engineer. */
272275
"CONTACT_DETAIL_COMM_TYPE_INSECURE" = "Unregistered Number";
273276

@@ -577,6 +580,12 @@
577580
/* Button label for the 'call group member' button */
578581
"GROUP_MEMBERS_CALL" = "Call";
579582

583+
/* Title for the 'members' section of the 'group members' view. */
584+
"GROUP_MEMBERS_SECTION_TITLE_MEMBERS" = "Members";
585+
586+
/* Title for the 'no longer verified' section of the 'group members' view. */
587+
"GROUP_MEMBERS_SECTION_TITLE_NO_LONGER_VERIFIED" = "No Longer Marked as Verified";
588+
580589
/* Button label for the 'send message to group member' button */
581590
"GROUP_MEMBERS_SEND_MESSAGE" = "Send Message";
582591

@@ -1441,6 +1450,9 @@
14411450
/* Label for button or row which allows users to verify the safety number of another user. */
14421451
"VERIFY_PRIVACY" = "Show Safety Number";
14431452

1453+
/* Label for button or row which allows users to verify the safety numbers of multiple users. */
1454+
"VERIFY_PRIVACY_MULTIPLE" = "Review Safety Numbers";
1455+
14441456
/* Indicates how to cancel a voice message. */
14451457
"VOICE_MESSAGE_CANCEL_INSTRUCTIONS" = "Slide to Cancel";
14461458

0 commit comments

Comments
 (0)