From 86c524ddbc251f53a8aa542d1d3666bdceff5f10 Mon Sep 17 00:00:00 2001 From: jackflips Date: Wed, 21 Jan 2015 23:49:19 -1000 Subject: [PATCH] Fixing crashes when deleting single messages. --- Signal/src/view controllers/FingerprintViewController.h | 1 + Signal/src/view controllers/FingerprintViewController.m | 7 +++++++ Signal/src/view controllers/MessagesViewController.m | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Signal/src/view controllers/FingerprintViewController.h b/Signal/src/view controllers/FingerprintViewController.h index 3accbd335..d127e70bd 100644 --- a/Signal/src/view controllers/FingerprintViewController.h +++ b/Signal/src/view controllers/FingerprintViewController.h @@ -8,6 +8,7 @@ #import #import "TSContactThread.h" +#import "MessagesViewController.h" @interface FingerprintViewController : UIViewController diff --git a/Signal/src/view controllers/FingerprintViewController.m b/Signal/src/view controllers/FingerprintViewController.m index bf56ceaa7..d0a561b9a 100644 --- a/Signal/src/view controllers/FingerprintViewController.m +++ b/Signal/src/view controllers/FingerprintViewController.m @@ -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:^{ diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index ffbd64f03..316c5e1b7 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -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; }