|
|
|
|
@ -228,7 +228,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
- (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
{
|
|
|
|
|
for (id<OWSReadTracking> message in [self unseenMessagesWithTransaction:transaction]) {
|
|
|
|
|
[message markAsReadWithTransaction:transaction sendReadReceipt:YES];
|
|
|
|
|
[message markAsReadWithTransaction:transaction sendReadReceipt:YES updateExpiration:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Just to be defensive, we'll also check for unread messages.
|
|
|
|
|
@ -243,6 +243,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
return (TSInteraction *)last;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (TSInteraction *)lastInteractionForInbox
|
|
|
|
|
{
|
|
|
|
|
__block TSInteraction *last;
|
|
|
|
|
[TSStorageManager.sharedManager.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
|
last = [[transaction ext:TSThreadInboxMessagesDatabaseViewExtensionName] lastObjectInGroup:self.uniqueId];
|
|
|
|
|
}];
|
|
|
|
|
return (TSInteraction *)last;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSDate *)lastMessageDate {
|
|
|
|
|
if (_lastMessageDate) {
|
|
|
|
|
return _lastMessageDate;
|
|
|
|
|
@ -252,22 +261,50 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)lastMessageLabel {
|
|
|
|
|
if (self.lastInteraction == nil) {
|
|
|
|
|
TSInteraction *interaction = self.lastInteractionForInbox;
|
|
|
|
|
if (interaction == nil) {
|
|
|
|
|
return @"";
|
|
|
|
|
} else {
|
|
|
|
|
return [self lastInteraction].description;
|
|
|
|
|
return interaction.description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (BOOL)shouldInteractionAppearInInbox:(TSInteraction *)interaction
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(interaction);
|
|
|
|
|
|
|
|
|
|
if (interaction.isDynamicInteraction) {
|
|
|
|
|
DDLogDebug(@"%@ not showing dynamic interaction in inbox: %@", self.tag, interaction.debugDescription);
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ([interaction isKindOfClass:[TSErrorMessage class]]) {
|
|
|
|
|
TSErrorMessage *errorMessage = (TSErrorMessage *)interaction;
|
|
|
|
|
if (errorMessage.errorType == TSErrorMessageNonBlockingIdentityChange) {
|
|
|
|
|
// Otherwise all group threads with the recipient will percolate to the top of the inbox, even though
|
|
|
|
|
// there was no meaningful interaction.
|
|
|
|
|
DDLogDebug(
|
|
|
|
|
@"%@ not showing nonblocking identity change in inbox: %@", self.tag, errorMessage.debugDescription);
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
} else if ([interaction isKindOfClass:[TSInfoMessage class]]) {
|
|
|
|
|
TSInfoMessage *infoMessage = (TSInfoMessage *)interaction;
|
|
|
|
|
if (infoMessage.messageType == TSInfoMessageVerificationStateChange) {
|
|
|
|
|
DDLogDebug(
|
|
|
|
|
@"%@ not showing verification state change in inbox: %@", self.tag, infoMessage.debugDescription);
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateWithLastMessage:(TSInteraction *)lastMessage transaction:(YapDatabaseReadWriteTransaction *)transaction {
|
|
|
|
|
OWSAssert(lastMessage);
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
if (lastMessage.isDynamicInteraction) {
|
|
|
|
|
DDLogDebug(@"%@ not updating lastMessage for thread: %@ dynamic interaction: %@",
|
|
|
|
|
self.tag,
|
|
|
|
|
self,
|
|
|
|
|
lastMessage.debugDescription);
|
|
|
|
|
if (![self.class shouldInteractionAppearInInbox:lastMessage]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|