From c1a2f006be352ab7d28769a2950ba5771d4c258b Mon Sep 17 00:00:00 2001 From: Frederic Jacobs Date: Sat, 21 Feb 2015 04:06:35 +0100 Subject: [PATCH] Fixes bug spotted by @jlund with the unread count. --- Signal/src/textsecure/Contacts/TSThread.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Signal/src/textsecure/Contacts/TSThread.m b/Signal/src/textsecure/Contacts/TSThread.m index a0ee96854..60b2e51de 100644 --- a/Signal/src/textsecure/Contacts/TSThread.m +++ b/Signal/src/textsecure/Contacts/TSThread.m @@ -143,9 +143,12 @@ - (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction*)transaction { YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSUnreadDatabaseViewExtensionName]; - NSUInteger numberOfItemsInSection = [viewTransaction numberOfItemsInGroup:self.uniqueId]; - for (NSUInteger i = 0; i < numberOfItemsInSection; i++) { - TSIncomingMessage *message = [viewTransaction objectAtIndex:i inGroup:self.uniqueId]; + NSMutableArray *array = [NSMutableArray array]; + [viewTransaction enumerateRowsInGroup:self.uniqueId usingBlock:^(NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) { + [array addObject:object]; + }]; + + for (TSIncomingMessage *message in array) { message.read = YES; [message saveWithTransaction:transaction]; }