Flush writes from other processes.

pull/1/head
Matthew Chen 7 years ago
parent 1ff4f85247
commit 4e1e232825

@ -4170,9 +4170,11 @@ typedef enum : NSUInteger {
if (hasAddedNewItems) { if (hasAddedNewItems) {
NSIndexPath *_Nullable indexPathToShow = [self firstIndexPathAtPreviousLastUnreadTimestamp]; NSIndexPath *_Nullable indexPathToShow = [self firstIndexPathAtPreviousLastUnreadTimestamp];
if (indexPathToShow) { if (indexPathToShow) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.collectionView scrollToItemAtIndexPath:indexPathToShow [self.collectionView scrollToItemAtIndexPath:indexPathToShow
atScrollPosition:UICollectionViewScrollPositionCenteredVertically atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:YES]; animated:YES];
});
} }
} }
self.previousLastUnreadTimestamp = nil; self.previousLastUnreadTimestamp = nil;
@ -4307,6 +4309,14 @@ typedef enum : NSUInteger {
[self ensureDynamicInteractions]; [self ensureDynamicInteractions];
[self updateBackButtonUnreadCount]; [self updateBackButtonUnreadCount];
[self updateNavigationBarSubtitleLabel]; [self updateNavigationBarSubtitleLabel];
// There appears to be a bug in YapDatabase that sometimes delays modifications
// made in another process (e.g. the SAE) from showing up in other processes.
// There's a simple workaround: a trivial write to the database flushes changes
// made from other processes.
[self.editingDatabaseConnection setObject:[NSUUID UUID].UUIDString
forKey:@"conversation_view_noop_mod"
inCollection:@"temp"];
} }
#pragma mark - ConversationCollectionViewDelegate #pragma mark - ConversationCollectionViewDelegate

@ -76,7 +76,10 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
OWSAssert(delegate); OWSAssert(delegate);
OWSAssert(delegate.areAllRegistrationsComplete || self.canWriteBeforeStorageReady); OWSAssert(delegate.areAllRegistrationsComplete || self.canWriteBeforeStorageReady);
OWSBackgroundTask *backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; OWSBackgroundTask *_Nullable backgroundTask = nil;
if (CurrentAppContext().isMainApp) {
backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
}
[super readWriteWithBlock:block]; [super readWriteWithBlock:block];
backgroundTask = nil; backgroundTask = nil;
} }
@ -100,7 +103,10 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
OWSAssert(delegate); OWSAssert(delegate);
OWSAssert(delegate.areAllRegistrationsComplete || self.canWriteBeforeStorageReady); OWSAssert(delegate.areAllRegistrationsComplete || self.canWriteBeforeStorageReady);
__block OWSBackgroundTask *backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; __block OWSBackgroundTask *_Nullable backgroundTask = nil;
if (CurrentAppContext().isMainApp) {
backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
}
[super asyncReadWriteWithBlock:block completionQueue:completionQueue completionBlock:^{ [super asyncReadWriteWithBlock:block completionQueue:completionQueue completionBlock:^{
if (completionBlock) { if (completionBlock) {
completionBlock(); completionBlock();

Loading…
Cancel
Save