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:) selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification name:YapDatabaseModifiedNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedExternallyNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:) selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification name:UIApplicationWillEnterForegroundNotification

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

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

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

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

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

@ -11,6 +11,7 @@
#import "TSOutgoingMessage.h" #import "TSOutgoingMessage.h"
#import "TSStorageManager.h" #import "TSStorageManager.h"
#import "TSThread.h" #import "TSThread.h"
#import <YapDatabase/YapDatabaseCrossProcessNotification.h>
#import <YapDatabase/YapDatabaseView.h> #import <YapDatabase/YapDatabaseView.h>
NSString *const kNSNotificationName_DatabaseViewRegistrationComplete = 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 + (void)registerMessageDatabaseViewWithName:(NSString *)viewName
viewGrouping:(YapDatabaseViewGrouping *)viewGrouping viewGrouping:(YapDatabaseViewGrouping *)viewGrouping
version:(NSString *)version version:(NSString *)version

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

Loading…
Cancel
Save