Fixing crashes when deleting single messages.

This commit is contained in:
jackflips 2015-01-21 23:49:19 -10:00 committed by Frederic Jacobs
parent 1eef08628a
commit 86c524ddbc
3 changed files with 9 additions and 2 deletions

View file

@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import "TSContactThread.h"
#import "MessagesViewController.h"
@interface FingerprintViewController : UIViewController

View file

@ -147,6 +147,13 @@
}
- (void)shredDiscussionsWithContact {
UINavigationController *nVC = (UINavigationController*)self.presentingViewController;
for (UIViewController __strong *vc in nVC.viewControllers) {
if ([vc isKindOfClass:[MessagesViewController class]]) {
vc = nil;
}
}
[self.thread remove]; // this removes the thread and all it's discussion (YapDatabaseRelationships)
__block SignalsNavigationController *vc = (SignalsNavigationController*)[self presentingViewController];
[vc dismissViewControllerAnimated:YES completion:^{

View file

@ -856,6 +856,7 @@ typedef enum : NSUInteger {
- (void)deleteMessageAtIndexPath:(NSIndexPath*)indexPath {
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSInteraction *interaction = [self interactionAtIndexPath:indexPath];
[[TSAdapterCacheManager sharedManager] clearCacheEntryForInteractionId:interaction.uniqueId];
[interaction removeWithTransaction:transaction];
}];
}
@ -1193,8 +1194,6 @@ typedef enum : NSUInteger {
{
case YapDatabaseViewChangeDelete :
{
TSInteraction * interaction = [self interactionAtIndexPath:rowChange.indexPath];
[[TSAdapterCacheManager sharedManager] clearCacheEntryForInteractionId:interaction.uniqueId];
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
break;
}