|
|
@ -72,11 +72,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName];
|
|
|
|
YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName];
|
|
|
|
NSArray<NSString *> *allGroups = [unreadMessages allGroups];
|
|
|
|
NSArray<NSString *> *allGroups = [unreadMessages allGroups];
|
|
|
|
|
|
|
|
// FIXME: Confusingly, `allGroups` includes contact threads as well
|
|
|
|
for (NSString *groupID in allGroups) {
|
|
|
|
for (NSString *groupID in allGroups) {
|
|
|
|
TSGroupThread *thread = [TSGroupThread fetchObjectWithUniqueID:groupID transaction:transaction];
|
|
|
|
TSThread *thread = [TSThread fetchObjectWithUniqueID:groupID transaction:transaction];
|
|
|
|
if (thread.isMuted) continue;
|
|
|
|
if (thread.isMuted) { continue; }
|
|
|
|
|
|
|
|
BOOL isGroupThread = thread.isGroupThread;
|
|
|
|
[unreadMessages enumerateKeysAndObjectsInGroup:groupID
|
|
|
|
[unreadMessages enumerateKeysAndObjectsInGroup:groupID
|
|
|
|
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
|
|
|
|
usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) {
|
|
|
|
if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
|
|
|
|
if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,9 +87,11 @@ 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TSIncomingMessage * incomingMessage = (TSIncomingMessage *)object;
|
|
|
|
if ([object isKindOfClass:TSIncomingMessage.class] && isGroupThread) {
|
|
|
|
if (incomingMessage != nil && thread.isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned) {
|
|
|
|
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)object;
|
|
|
|
return;
|
|
|
|
if (((TSGroupThread *)thread).isOnlyNotifyingForMentions && !incomingMessage.isUserMentioned) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count += 1;
|
|
|
|
count += 1;
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|