Merge branch 'charlesmchen/crossProcessDBModifications'

pull/1/head
Matthew Chen 7 years ago
commit 14d5950624

@ -291,6 +291,10 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification

@ -136,6 +136,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:nil];
}
- (void)dealloc

@ -66,7 +66,10 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
object:self.dbConnection.database];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:self.dbConnection.database];
self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(refreshDevices) forControlEvents:UIControlEventValueChanged];

@ -72,6 +72,10 @@ NS_ASSUME_NONNULL_BEGIN
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
object:database];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:database];
}
return _uiDatabaseConnection;
}

@ -125,6 +125,10 @@ NS_ASSUME_NONNULL_BEGIN
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:nil];
}
- (void)yapDatabaseModified:(NSNotification *)notification

@ -25,6 +25,8 @@ extern NSString *const TSSecondaryDevicesDatabaseViewExtensionName;
// This method can be called from any thread.
+ (BOOL)hasPendingViewRegistrations;
+ (void)registerCrossProcessNotifier;
// This method must be called _AFTER_ registerThreadInteractionsDatabaseView.
+ (void)registerThreadDatabaseView;

@ -11,6 +11,7 @@
#import "TSOutgoingMessage.h"
#import "TSStorageManager.h"
#import "TSThread.h"
#import <YapDatabase/YapDatabaseCrossProcessNotification.h>
#import <YapDatabase/YapDatabaseView.h>
NSString *const kNSNotificationName_DatabaseViewRegistrationComplete =
@ -88,6 +89,15 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
}
}
+ (void)registerCrossProcessNotifier
{
// I don't think the identifier and name of this extension matter for our purposes,
// so long as they don't conflict with any other extension names.
YapDatabaseExtension *extension =
[[YapDatabaseCrossProcessNotification alloc] initWithIdentifier:@"SignalCrossProcessNotifier"];
[[TSStorageManager sharedManager].database registerExtension:extension withName:@"SignalCrossProcessNotifier"];
}
+ (void)registerMessageDatabaseViewWithName:(NSString *)viewName
viewGrouping:(YapDatabaseViewGrouping *)viewGrouping
version:(NSString *)version

@ -310,6 +310,7 @@ void setDatabaseInitialized()
- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)())safeBlockingMigrationsBlock
{
// Synchronously register extensions which are essential for views.
[TSDatabaseView registerCrossProcessNotifier];
[TSDatabaseView registerThreadInteractionsDatabaseView];
[TSDatabaseView registerThreadDatabaseView];
[TSDatabaseView registerUnreadDatabaseView];

Loading…
Cancel
Save