From 02c7a52a641088dacc220112e4a816e6ed17f9ea Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 7 Dec 2018 11:37:21 -0500 Subject: [PATCH] Refine conversation delete/archive. --- .../HomeView/HomeViewController.m | 39 ++++++++++--------- .../translations/en.lproj/Localizable.strings | 9 +++-- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 6058a6006..446326f74 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -947,7 +947,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations }); } -#pragma mark Table Swipe to Delete +#pragma mark - Edit Actions - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle @@ -992,7 +992,11 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations }]; } - return @[ deleteAction, archiveAction ]; + // The first action will be auto-performed for "very long swipes". + return @[ + archiveAction, + deleteAction, + ]; } case HomeViewControllerSectionArchiveButton: { return @[]; @@ -1113,22 +1117,21 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations TSThread *thread = [self threadForIndexPath:indexPath]; - if (![thread isKindOfClass:[TSGroupThread class]]) { - [self deleteThread:thread]; - return; - } - - TSGroupThread *gThread = (TSGroupThread *)thread; - if (![gThread.groupModel.groupMemberIds containsObject:[TSAccountManager localNumber]]) { - [self deleteThread:thread]; - return; - } - - [ThreadUtil enqueueLeaveGroupMessageInThread:gThread]; - - // MJK TODO - DURABLE TESTPLAN is this safe to delete the gThread when the outgoing message hasn't completed - // sending? - [self deleteThread:thread]; + __weak HomeViewController *weakSelf = self; + UIAlertController *alert = + [UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONVERSATION_DELETE_CONFIRMATION_ALERT_TITLE", + @"Title for the 'conversation delete confirmation' alert.") + message:NSLocalizedString(@"CONVERSATION_DELETE_CONFIRMATION_ALERT_MESSAGE", + @"Message for the 'conversation delete confirmation' alert.") + preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_DELETE_TITLE", nil) + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *action) { + [weakSelf deleteThread:thread]; + }]]; + [alert addAction:[OWSAlerts cancelAction]]; + + [self presentViewController:alert animated:YES completion:nil]; } - (void)deleteThread:(TSThread *)thread diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index f72fa73ca..662186aab 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -191,9 +191,6 @@ /* Error indicating that the app received an invalid response from CloudKit. */ "BACKUP_EXPORT_ERROR_INVALID_CLOUDKIT_RESPONSE" = "Invalid Service Response"; -/* Error indicating the backup export failed to save a file to the cloud. */ -"BACKUP_EXPORT_ERROR_SAVE_FILE_TO_CLOUD_FAILED" = "Backup data could not be uploaded."; - /* Indicates that the cloud is being cleaned up. */ "BACKUP_EXPORT_PHASE_CLEAN_UP" = "Cleaning Up Backup"; @@ -557,6 +554,12 @@ /* Indicates that a contact has no name. */ "CONTACT_WITHOUT_NAME" = "Unnamed Contact"; +/* Message for the 'conversation delete confirmation' alert. */ +"CONVERSATION_DELETE_CONFIRMATION_ALERT_MESSAGE" = "This cannot be undone."; + +/* Title for the 'conversation delete confirmation' alert. */ +"CONVERSATION_DELETE_CONFIRMATION_ALERT_TITLE" = "Delete Conversation?"; + /* title for conversation settings screen */ "CONVERSATION_SETTINGS" = "Conversation Settings";