Archiving and correctly sorting empty threads.

pull/1/head
Christine Corbett 10 years ago committed by Frederic Jacobs
parent aca02221be
commit 553a38288e

@ -64,6 +64,7 @@ typedef NS_ENUM(NSInteger, TSLastActionType) {
@property (getter=isBlocked) BOOL blocked; @property (getter=isBlocked) BOOL blocked;
@property (nonatomic) NSString* latestMessageId; @property (nonatomic) NSString* latestMessageId;
@property NSDate *archivalDate; @property NSDate *archivalDate;
@property (nonatomic) NSDate *creationDate;
- (NSDate*)lastMessageDate; - (NSDate*)lastMessageDate;

@ -30,6 +30,7 @@
if (self) { if (self) {
_blocked = NO; _blocked = NO;
_latestMessageId = nil; _latestMessageId = nil;
_creationDate = [NSDate date];
} }
return self; return self;
@ -51,9 +52,13 @@
if (date) { if (date) {
return date; return date;
} }
else {
return [NSDate date];
}
}
else {
return _creationDate;
} }
return [NSDate date];
} }
- (UIImage*)image{ - (UIImage*)image{

@ -67,10 +67,15 @@ NSString *TSUnreadDatabaseViewExtensionName = @"TSUnreadDatabaseViewExtensionNa
YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *(NSString *collection, NSString *key, id object) { YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *(NSString *collection, NSString *key, id object) {
if ([object isKindOfClass:[TSThread class]]){ if ([object isKindOfClass:[TSThread class]]){
TSThread *thread = (TSThread*)object; TSThread *thread = (TSThread*)object;
if (thread.archivalDate) { if (thread.archivalDate&&[thread.latestMessageId length]>0) {
return ([self threadShouldBeInInbox:thread])?TSInboxGroup:TSArchiveGroup; return ([self threadShouldBeInInbox:thread])?TSInboxGroup:TSArchiveGroup;
} }
return TSInboxGroup; else if(thread.archivalDate) {
return TSArchiveGroup;
}
else {
return TSInboxGroup;
}
} }
return nil; return nil;
}]; }];

@ -226,7 +226,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow";
MessagesViewController * vc = [segue destinationViewController]; MessagesViewController * vc = [segue destinationViewController];
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
TSThread *thread = [self threadForIndexPath:selectedIndexPath]; TSThread *thread = [self threadForIndexPath:selectedIndexPath];
[self selectedInbox:self];
if (self.contactIdentifierFromCompose){ if (self.contactIdentifierFromCompose){
[vc setupWithTSIdentifier:self.contactIdentifierFromCompose]; [vc setupWithTSIdentifier:self.contactIdentifierFromCompose];
self.contactIdentifierFromCompose = nil; self.contactIdentifierFromCompose = nil;
@ -238,6 +238,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow";
else if (thread) { else if (thread) {
[vc setupWithThread:thread]; [vc setupWithThread:thread];
} }
} }
else if ([segue.identifier isEqualToString:kCallSegue]) { else if ([segue.identifier isEqualToString:kCallSegue]) {
InCallViewController* vc = [segue destinationViewController]; InCallViewController* vc = [segue destinationViewController];

Loading…
Cancel
Save