Merge remote-tracking branch 'private/mkirk/soft-delete' into release/2.42.4

This commit is contained in:
Matthew Chen 2019-09-12 15:56:31 -03:00
commit a46ea14756
7 changed files with 30 additions and 25 deletions

View File

@ -5262,12 +5262,10 @@ typedef enum : NSUInteger {
[self.messageSenderJobQueue addMessage:message transaction:transaction];
[groupThread leaveGroupWithTransaction:transaction];
}
[groupThread softDeleteGroupThreadWithTransaction:transaction];
} else {
[self.thread anyRemoveWithTransaction:transaction];
}
[self.thread softDeleteThreadWithTransaction:transaction];
[transaction addCompletionWithBlock:^{
[self.navigationController popViewControllerAnimated:YES];
}];

View File

@ -1378,12 +1378,14 @@ NSString *const kArchiveButtonPseudoGroup = @"kArchiveButtonPseudoGroup";
if ([thread isKindOfClass:[TSGroupThread class]]) {
TSGroupThread *groupThread = (TSGroupThread *)thread;
if (groupThread.isLocalUserInGroup) {
[groupThread softDeleteGroupThreadWithTransaction:transaction];
return;
[groupThread softDeleteThreadWithTransaction:transaction];
} else {
[groupThread anyRemoveWithTransaction:transaction];
}
} else {
// contact thread
[thread softDeleteThreadWithTransaction:transaction];
}
[thread anyRemoveWithTransaction:transaction];
}];
[self updateViewState];

View File

@ -290,12 +290,17 @@ public class FullTextSearcher: NSObject {
let sortKey = ConversationSortKey(creationDate: thread.creationDate,
lastMessageReceivedAtDate: thread.lastInteractionForInbox(transaction: transaction)?.receivedAtDate())
let searchResult = ConversationSearchResult(thread: threadViewModel, sortKey: sortKey)
if let contactThread = thread as? TSContactThread {
existingConversationAddresses.insert(contactThread.contactAddress)
switch thread {
case is TSGroupThread:
conversations.append(searchResult)
case let contactThread as TSContactThread:
if contactThread.shouldThreadBeVisible {
existingConversationAddresses.insert(contactThread.contactAddress)
conversations.append(searchResult)
}
default:
owsFailDebug("unexpected thread: \(type(of: thread))")
}
conversations.append(searchResult)
} else if let message = match as? TSMessage {
let thread = message.thread(transaction: transaction)

View File

@ -138,6 +138,8 @@ NS_SWIFT_NAME(init(uniqueId:archivalDate:archivedAsOfMessageSortId:conversationC
*/
- (void)archiveThreadWithTransaction:(SDSAnyWriteTransaction *)transaction;
- (void)softDeleteThreadWithTransaction:(SDSAnyWriteTransaction *)transaction;
/**
* Unarchives a thread
*

View File

@ -447,6 +447,16 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
}
}
- (void)softDeleteThreadWithTransaction:(SDSAnyWriteTransaction *)transaction
{
[self removeAllThreadInteractionsWithTransaction:transaction];
[self anyUpdateWithTransaction:transaction
block:^(TSThread *thread) {
thread.messageDraft = nil;
thread.shouldThreadBeVisible = NO;
}];
}
#pragma mark - Disappearing Messages
- (OWSDisappearingMessagesConfiguration *)disappearingMessagesConfigurationWithTransaction:

View File

@ -69,8 +69,6 @@ NS_SWIFT_NAME(init(uniqueId:archivalDate:archivedAsOfMessageSortId:conversationC
- (void)leaveGroupWithSneakyTransaction;
- (void)leaveGroupWithTransaction:(SDSAnyWriteTransaction *)transaction;
- (void)softDeleteGroupThreadWithTransaction:(SDSAnyWriteTransaction *)transaction;
#pragma mark - Avatar
- (void)updateAvatarWithAttachmentStream:(TSAttachmentStream *)attachmentStream;

View File

@ -260,16 +260,6 @@ isArchivedByLegacyTimestampForSorting:isArchivedByLegacyTimestampForSorting
}];
}
- (void)softDeleteGroupThreadWithTransaction:(SDSAnyWriteTransaction *)transaction
{
[self removeAllThreadInteractionsWithTransaction:transaction];
[self anyUpdateGroupThreadWithTransaction:transaction
block:^(TSGroupThread *thread) {
thread.shouldThreadBeVisible = NO;
}];
}
#pragma mark - Avatar
- (void)updateAvatarWithAttachmentStream:(TSAttachmentStream *)attachmentStream