clean up some code related to unread message (requests) count

pull/541/head
Ryan Zhao 3 years ago
parent daf0705d42
commit 3ab7192b26

@ -91,6 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
NSLog(@"Found an already read message in the * unread * messages list."); NSLog(@"Found an already read message in the * unread * messages list.");
return; return;
} }
// We have to filter those unread messages for groups that only notifiy for mentions
if ([object isKindOfClass:TSIncomingMessage.class] && isGroupThread) { if ([object isKindOfClass:TSIncomingMessage.class] && isGroupThread) {
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)object; TSIncomingMessage *incomingMessage = (TSIncomingMessage *)object;
if (((TSGroupThread *)thread).isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned) { if (((TSGroupThread *)thread).isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned) {
@ -103,13 +104,6 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
return count; return count;
__block NSUInteger numberOfItems;
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
numberOfItems = [[transaction ext:TSUnreadDatabaseViewExtensionName] numberOfItemsInAllGroups];
}];
return numberOfItems;
} }
- (NSUInteger)unreadMessageRequestCount { - (NSUInteger)unreadMessageRequestCount {
@ -124,20 +118,9 @@ NS_ASSUME_NONNULL_BEGIN
// Only increase the count for message requests // Only increase the count for message requests
if (!thread.isMessageRequest) { continue; } if (!thread.isMessageRequest) { continue; }
if ([unreadMessages numberOfItemsInGroup:groupID] > 0) {
[unreadMessages enumerateKeysAndObjectsInGroup:groupID
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
return;
}
id<OWSReadTracking> unread = (id<OWSReadTracking>)object;
if (unread.read) {
NSLog(@"Found an already read message in the * unread * messages list.");
return;
}
count += 1; count += 1;
*stop = YES; }
}];
} }
}]; }];

Loading…
Cancel
Save