From fc061d2a341397f632432fc9da4b6ed1423a68ef Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 17 Apr 2020 19:29:40 +0200 Subject: [PATCH] Fix computeRelevantUnreadCount #3 --- .../quassel-for-ios/QuasselCoreConnection.m | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/quassel-for-ios/quassel-for-ios/QuasselCoreConnection.m b/quassel-for-ios/quassel-for-ios/QuasselCoreConnection.m index a5286e1..511e41f 100644 --- a/quassel-for-ios/quassel-for-ios/QuasselCoreConnection.m +++ b/quassel-for-ios/quassel-for-ios/QuasselCoreConnection.m @@ -1423,26 +1423,24 @@ - (int) computeUnreadCountForBuffer:(BufferId*)bufferId return 0; NSArray *messages = [bufferIdMessageListMap objectForKey:bufferId]; __block int unreadCount = 0; + __block BOOL seenAtAll = NO; [messages enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) { MsgId *currentId = [obj messageId]; - NSLog(@"Comparing %@ (current) with %@ (last seen)", currentId, lastSeenMsgId); - if ([currentId isEqual:lastSeenMsgId]) { - NSLog(@"EQUAL!"); + //NSLog(@"Comparing %@ (current) with %@ (last seen) %@", currentId, lastSeenMsgId, [obj contents]); + if (lastSeenMsgId.intValue >= currentId.intValue) { + //NSLog(@"SEEN!"); + seenAtAll = YES; *stop = YES; return; } unreadCount++; }]; - return unreadCount; - // - // for (int i = messages.count-1; i >= 0; i--) - // { - // if ([[[messages objectAtIndex:i] messageId] isEqual:lastSeenMsgId]) { - // int unreadCount = messages.count - i - 1; - // return unreadCount; - // } - // } - // return messages.count; + if (seenAtAll) { + return unreadCount; + } else { + NSLog(@"Probably not seen"); + return 0; + } } - (void) sendMessage:(NSString*)msg toBuffer:(BufferId*)bufferId