Skip to content

Commit

Permalink
Fix computeRelevantUnreadCount #3
Browse files Browse the repository at this point in the history
  • Loading branch information
guruz committed Apr 17, 2020
1 parent 9df570b commit fc061d2
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions quassel-for-ios/quassel-for-ios/QuasselCoreConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc061d2

Please sign in to comment.