Increase cache, remove dead code, add debug logging

// FREEBIE
pull/1/head
Michael Kirk 6 years ago
parent b3cd6a112b
commit 1f63ce02a0

@ -947,6 +947,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
if (!_uiDatabaseConnection) {
_uiDatabaseConnection = [OWSPrimaryStorage.sharedManager newDatabaseConnection];
// default is 250
_uiDatabaseConnection.objectCacheLimit = 500;
[_uiDatabaseConnection beginLongLivedReadTransaction];
}
return _uiDatabaseConnection;

@ -65,13 +65,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *)receivedMessagesForInvalidKey:(NSData *)key;
/**
* Returns whether or not the thread has unread messages.
*
* @return YES if it has unread TSIncomingMessages, NO otherwise.
*/
- (BOOL)hasUnreadMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(hasUnreadMessages(transaction:));
- (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction
NS_SWIFT_NAME(unreadMessageCount(transaction:));

@ -200,18 +200,6 @@ NS_ASSUME_NONNULL_BEGIN
return count;
}
- (BOOL)hasUnreadMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
{
TSInteraction *interaction = [self lastInteractionWithTransaction:transaction];
BOOL hasUnread = NO;
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
hasUnread = ![(TSIncomingMessage *)interaction wasRead];
}
return hasUnread;
}
- (NSArray<id<OWSReadTracking>> *)unseenMessagesWithTransaction:(YapDatabaseReadTransaction *)transaction
{
NSMutableArray<id<OWSReadTracking>> *messages = [NSMutableArray new];
@ -245,13 +233,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert([self unseenMessagesWithTransaction:transaction].count < 1);
}
- (TSInteraction *)lastInteractionWithTransaction:(YapDatabaseReadTransaction *)transaction
{
return [[transaction ext:TSMessageDatabaseViewExtensionName] lastObjectInGroup:self.uniqueId];
}
- (TSInteraction *)lastInteractionForInboxWithTransaction:(YapDatabaseReadTransaction *)transaction
{
__block NSUInteger missedCount = 0;
__block TSInteraction *last = nil;
[[transaction ext:TSMessageDatabaseViewExtensionName]
enumerateRowsInGroup:self.uniqueId
@ -260,11 +244,20 @@ NS_ASSUME_NONNULL_BEGIN
NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
OWSAssert([object isKindOfClass:[TSInteraction class]]);
missedCount++;
TSInteraction *interaction = (TSInteraction *)object;
if ([TSThread shouldInteractionAppearInInbox:interaction]) {
last = interaction;
// For long ignored threads, with lots of SN changes this can get really slow.
// I see this in development because I have a lot of long forgotten threads with members
// who's test devices are constantly reinstalled. We could add a purpose-built DB view,
// but I think in the real world this is rare to be a hotspot.
if (missedCount > 50) {
DDLogWarn(@"%@ found last interaction for inbox after skipping %tu items", self.logTag, missedCount);
}
*stop = YES;
}
}];

Loading…
Cancel
Save