From 553a38288ec2495aab6d7acdb24870ced68ed49b Mon Sep 17 00:00:00 2001 From: Christine Corbett Date: Wed, 28 Jan 2015 14:34:54 -1000 Subject: [PATCH] Archiving and correctly sorting empty threads. --- Signal/src/textsecure/Contacts/TSThread.h | 1 + Signal/src/textsecure/Contacts/TSThread.m | 9 +++++++-- Signal/src/textsecure/Storage/TSDatabaseView.m | 9 +++++++-- .../src/view controllers/UITests/SignalsViewController.m | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Signal/src/textsecure/Contacts/TSThread.h b/Signal/src/textsecure/Contacts/TSThread.h index ac2aca7ba..046383f0d 100644 --- a/Signal/src/textsecure/Contacts/TSThread.h +++ b/Signal/src/textsecure/Contacts/TSThread.h @@ -64,6 +64,7 @@ typedef NS_ENUM(NSInteger, TSLastActionType) { @property (getter=isBlocked) BOOL blocked; @property (nonatomic) NSString* latestMessageId; @property NSDate *archivalDate; +@property (nonatomic) NSDate *creationDate; - (NSDate*)lastMessageDate; diff --git a/Signal/src/textsecure/Contacts/TSThread.m b/Signal/src/textsecure/Contacts/TSThread.m index 19702bd79..8509f10c2 100644 --- a/Signal/src/textsecure/Contacts/TSThread.m +++ b/Signal/src/textsecure/Contacts/TSThread.m @@ -30,6 +30,7 @@ if (self) { _blocked = NO; _latestMessageId = nil; + _creationDate = [NSDate date]; } return self; @@ -51,9 +52,13 @@ if (date) { return date; } + else { + return [NSDate date]; + } + } + else { + return _creationDate; } - - return [NSDate date]; } - (UIImage*)image{ diff --git a/Signal/src/textsecure/Storage/TSDatabaseView.m b/Signal/src/textsecure/Storage/TSDatabaseView.m index 34cfc312d..2c9289261 100644 --- a/Signal/src/textsecure/Storage/TSDatabaseView.m +++ b/Signal/src/textsecure/Storage/TSDatabaseView.m @@ -67,10 +67,15 @@ NSString *TSUnreadDatabaseViewExtensionName = @"TSUnreadDatabaseViewExtensionNa YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *(NSString *collection, NSString *key, id object) { if ([object isKindOfClass:[TSThread class]]){ TSThread *thread = (TSThread*)object; - if (thread.archivalDate) { + if (thread.archivalDate&&[thread.latestMessageId length]>0) { return ([self threadShouldBeInInbox:thread])?TSInboxGroup:TSArchiveGroup; } - return TSInboxGroup; + else if(thread.archivalDate) { + return TSArchiveGroup; + } + else { + return TSInboxGroup; + } } return nil; }]; diff --git a/Signal/src/view controllers/UITests/SignalsViewController.m b/Signal/src/view controllers/UITests/SignalsViewController.m index a8b51ade5..9b13188ab 100644 --- a/Signal/src/view controllers/UITests/SignalsViewController.m +++ b/Signal/src/view controllers/UITests/SignalsViewController.m @@ -226,7 +226,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow"; MessagesViewController * vc = [segue destinationViewController]; NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; TSThread *thread = [self threadForIndexPath:selectedIndexPath]; - + [self selectedInbox:self]; if (self.contactIdentifierFromCompose){ [vc setupWithTSIdentifier:self.contactIdentifierFromCompose]; self.contactIdentifierFromCompose = nil; @@ -238,6 +238,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow"; else if (thread) { [vc setupWithThread:thread]; } + } else if ([segue.identifier isEqualToString:kCallSegue]) { InCallViewController* vc = [segue destinationViewController];