Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 622c0c3f5f
commit 164bf19b47

@ -598,6 +598,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
#ifdef DEBUG
- (void)clearProfileWhitelist
{
DDLogWarn(@"%@ Clearing the profile whitelist.", self.tag);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@synchronized(self)
{
@ -621,8 +623,20 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
DDLogError(@"groupProfileWhitelistCache: %zd", self.groupProfileWhitelistCache.count);
DDLogError(@"kOWSProfileManager_UserWhitelistCollection: %zd",
[self.dbConnection numberOfKeysInCollection:kOWSProfileManager_UserWhitelistCollection]);
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[transaction enumerateKeysInCollection:kOWSProfileManager_UserWhitelistCollection
usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) {
DDLogError(@"\t profile whitelist user: %@", key);
}];
}];
DDLogError(@"kOWSProfileManager_GroupWhitelistCollection: %zd",
[self.dbConnection numberOfKeysInCollection:kOWSProfileManager_GroupWhitelistCollection]);
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[transaction enumerateKeysInCollection:kOWSProfileManager_GroupWhitelistCollection
usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) {
DDLogError(@"\t profile whitelist group: %@", key);
}];
}];
}
});
}

@ -38,8 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL hasMoreUnseenMessages;
@property (nonatomic, readonly) BOOL didInsertDynamicInteractions;
- (void)clearUnreadIndicatorState;
@end

@ -28,8 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) BOOL hasMoreUnseenMessages;
@property (nonatomic) BOOL didInsertDynamicInteractions;
@end
#pragma mark -
@ -400,7 +398,10 @@ NS_ASSUME_NONNULL_BEGIN
const int kAddToContactsOfferOffset = -2;
const int kUnreadIndicatorOfferOffset = -1;
// Ensure dynamic interactions have a non-negative timestamp even if the conversation was empty.
// We want the offers to be the first interactions in their
// conversation's timeline, so we back-date them to slightly before
// the first message - or at an aribtrary old timestamp if the
// conversation has no messages.
long long startOfConversationTimestamp
= (long long)(firstMessage ? firstMessage.timestampForSorting : 1000);
@ -413,9 +414,6 @@ NS_ASSUME_NONNULL_BEGIN
} else if (!existingBlockOffer && shouldHaveBlockOffer) {
DDLogInfo(@"Creating block offer for unknown contact");
// We want the block offer to be the first interaction in their
// conversation's timeline, so we back-date it to slightly before
// the first incoming message (which we know is the first message).
uint64_t blockOfferTimestamp = (uint64_t)(startOfConversationTimestamp + kBlockOfferOffset);
NSString *recipientId = ((TSContactThread *)thread).contactIdentifier;
@ -424,7 +422,6 @@ NS_ASSUME_NONNULL_BEGIN
thread:thread
contactId:recipientId];
[offerMessage saveWithTransaction:transaction];
result.didInsertDynamicInteractions = YES;
DDLogInfo(@"%@ Creating block offer: %@ (%llu)",
self.tag,
@ -442,9 +439,6 @@ NS_ASSUME_NONNULL_BEGIN
DDLogInfo(@"%@ Creating 'add to contacts' offer for unknown contact", self.tag);
// We want the offer to be the first interaction in their
// conversation's timeline, so we back-date it to slightly before
// the first incoming message (which we know is the first message).
uint64_t offerTimestamp = (uint64_t)(startOfConversationTimestamp + kAddToContactsOfferOffset);
NSString *recipientId = ((TSContactThread *)thread).contactIdentifier;
@ -452,7 +446,6 @@ NS_ASSUME_NONNULL_BEGIN
thread:thread
contactId:recipientId];
[offerMessage saveWithTransaction:transaction];
result.didInsertDynamicInteractions = YES;
DDLogInfo(@"%@ Creating 'add to contacts' offer: %@ (%llu)",
self.tag,
@ -470,15 +463,11 @@ NS_ASSUME_NONNULL_BEGIN
DDLogInfo(@"%@ Creating 'add to profile whitelist' offer", self.tag);
// We want the offer to be the first interaction in their
// conversation's timeline, so we back-date it to slightly before
// the first incoming message (which we know is the first message).
uint64_t offerTimestamp = (uint64_t)(startOfConversationTimestamp + kAddToProfileWhitelistOfferOffset);
TSMessage *offerMessage =
[OWSAddToProfileWhitelistOfferMessage addToProfileWhitelistOfferMessage:offerTimestamp thread:thread];
[offerMessage saveWithTransaction:transaction];
result.didInsertDynamicInteractions = YES;
DDLogInfo(@"%@ Creating 'add to profile whitelist' offer: %@ (%llu)",
self.tag,
@ -519,7 +508,6 @@ NS_ASSUME_NONNULL_BEGIN
hasMoreUnseenMessages:result.hasMoreUnseenMessages
missingUnseenSafetyNumberChangeCount:missingUnseenSafetyNumberChangeCount];
[indicator saveWithTransaction:transaction];
result.didInsertDynamicInteractions = YES;
DDLogInfo(@"%@ Creating TSUnreadIndicatorInteraction: %@ (%llu)",
self.tag,

@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSUInteger)numberOfKeysInCollection:(NSString *)collection
{
__block NSUInteger result;
[self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self readWithBlock:^(YapDatabaseReadTransaction *transaction) {
result = [transaction numberOfKeysInCollection:collection];
}];
return result;

Loading…
Cancel
Save