Fixes bug spotted by @jlund with the unread count.

pull/1/head
Frederic Jacobs 10 years ago
parent 24616735e5
commit c1a2f006be

@ -143,9 +143,12 @@
- (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction*)transaction { - (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction*)transaction {
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSUnreadDatabaseViewExtensionName]; YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSUnreadDatabaseViewExtensionName];
NSUInteger numberOfItemsInSection = [viewTransaction numberOfItemsInGroup:self.uniqueId]; NSMutableArray *array = [NSMutableArray array];
for (NSUInteger i = 0; i < numberOfItemsInSection; i++) { [viewTransaction enumerateRowsInGroup:self.uniqueId usingBlock:^(NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
TSIncomingMessage *message = [viewTransaction objectAtIndex:i inGroup:self.uniqueId]; [array addObject:object];
}];
for (TSIncomingMessage *message in array) {
message.read = YES; message.read = YES;
[message saveWithTransaction:transaction]; [message saveWithTransaction:transaction];
} }

Loading…
Cancel
Save