Bubble collapse.

This commit is contained in:
Matthew Chen 2018-03-28 10:42:48 -04:00
parent 11819d9b8a
commit 4a4e9d1ce2
3 changed files with 22 additions and 2 deletions

View file

@ -43,6 +43,11 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray<OWSTableItem *> *items = [NSMutableArray new];
[items addObject:[OWSTableItem itemWithTitle:@"Delete all messages in thread"
actionBlock:^{
[DebugUIMessages deleteAllMessagesInThread:thread];
}]];
for (DebugUIMessagesAction *action in @[
[DebugUIMessages sendMessageVariationsAction:thread],
// Send Media
@ -2589,6 +2594,14 @@ NS_ASSUME_NONNULL_BEGIN
};
}
+ (void)deleteAllMessagesInThread:(TSThread *)thread
{
[OWSPrimaryStorage.sharedManager.newDatabaseConnection
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[thread removeAllThreadInteractionsWithTransaction:transaction];
}];
}
@end
NS_ASSUME_NONNULL_END

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSYapDatabaseObject.h"
@ -133,6 +133,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)unarchiveThreadWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)removeAllThreadInteractionsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
#pragma mark Drafts
/**

View file

@ -49,8 +49,13 @@ NS_ASSUME_NONNULL_BEGIN
- (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
[super removeWithTransaction:transaction];
[self removeAllThreadInteractionsWithTransaction:transaction];
[super removeWithTransaction:transaction];
}
- (void)removeAllThreadInteractionsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
// We can't safely delete interactions while enumerating them, so
// we collect and delete separately.
//