Register all database views asynchronously.

pull/1/head
Matthew Chen 7 years ago
parent eb180ba5c4
commit b21f793756

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "PushManager.h" #import "PushManager.h"
@ -9,6 +9,7 @@
#import "SignalApp.h" #import "SignalApp.h"
#import "ThreadUtil.h" #import "ThreadUtil.h"
#import <SignalMessaging/OWSContactsManager.h> #import <SignalMessaging/OWSContactsManager.h>
#import <SignalServiceKit/AppReadiness.h>
#import <SignalServiceKit/NSDate+OWS.h> #import <SignalServiceKit/NSDate+OWS.h>
#import <SignalServiceKit/OWSDevice.h> #import <SignalServiceKit/OWSDevice.h>
#import <SignalServiceKit/OWSMessageReceiver.h> #import <SignalServiceKit/OWSMessageReceiver.h>
@ -108,11 +109,15 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
{ {
DDLogInfo(@"%@ received remote notification", self.logTag); DDLogInfo(@"%@ received remote notification", self.logTag);
[self.messageFetcherJob run]; [AppReadiness runNowOrWhenAppIsReady:^{
[self.messageFetcherJob run];
}];
} }
- (void)applicationDidBecomeActive { - (void)applicationDidBecomeActive {
[self.messageFetcherJob run]; [AppReadiness runNowOrWhenAppIsReady:^{
[self.messageFetcherJob run];
}];
} }
/** /**

@ -62,16 +62,18 @@ class ContactsFrameworkContactStoreAdaptee: ContactStoreAdaptee {
@objc @objc
func didBecomeActive() { func didBecomeActive() {
let currentSortOrder = CNContactsUserDefaults.shared().sortOrder AppReadiness.runNowOr {
let currentSortOrder = CNContactsUserDefaults.shared().sortOrder
guard currentSortOrder != self.lastSortOrder else { guard currentSortOrder != self.lastSortOrder else {
// sort order unchanged // sort order unchanged
return return
} }
Logger.info("\(TAG) sort order changed: \(String(describing: self.lastSortOrder)) -> \(String(describing: currentSortOrder))") Logger.info("\(self.TAG) sort order changed: \(String(describing: self.lastSortOrder)) -> \(String(describing: currentSortOrder))")
self.lastSortOrder = currentSortOrder self.lastSortOrder = currentSortOrder
self.runChangeHandler() self.runChangeHandler()
}
} }
@objc @objc

@ -4,6 +4,7 @@
#import "OWSBlockingManager.h" #import "OWSBlockingManager.h"
#import "AppContext.h" #import "AppContext.h"
#import "AppReadiness.h"
#import "NSNotificationCenter+OWS.h" #import "NSNotificationCenter+OWS.h"
#import "OWSBlockedPhoneNumbersMessage.h" #import "OWSBlockedPhoneNumbersMessage.h"
#import "OWSMessageSender.h" #import "OWSMessageSender.h"
@ -288,10 +289,12 @@ NSString *const kOWSBlockingManager_SyncedBlockedPhoneNumbersKey = @"kOWSBlockin
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@synchronized(self) [AppReadiness runNowOrWhenAppIsReady:^{
{ @synchronized(self)
[self syncBlockedPhoneNumbersIfNecessary]; {
} [self syncBlockedPhoneNumbersIfNecessary];
}
}];
} }
@end @end

@ -4,6 +4,7 @@
#import "OWSDisappearingMessagesJob.h" #import "OWSDisappearingMessagesJob.h"
#import "AppContext.h" #import "AppContext.h"
#import "AppReadiness.h"
#import "ContactsManagerProtocol.h" #import "ContactsManagerProtocol.h"
#import "NSDate+OWS.h" #import "NSDate+OWS.h"
#import "NSTimer+OWS.h" #import "NSTimer+OWS.h"
@ -393,7 +394,9 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[self runNow]; [AppReadiness runNowOrWhenAppIsReady:^{
[self runNow];
}];
} }
- (void)applicationWillResignActive:(NSNotification *)notification - (void)applicationWillResignActive:(NSNotification *)notification

@ -4,6 +4,7 @@
#import "TSSocketManager.h" #import "TSSocketManager.h"
#import "AppContext.h" #import "AppContext.h"
#import "AppReadiness.h"
#import "Cryptography.h" #import "Cryptography.h"
#import "NSNotificationCenter+OWS.h" #import "NSNotificationCenter+OWS.h"
#import "NSTimer+OWS.h" #import "NSTimer+OWS.h"
@ -608,6 +609,10 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
if (!AppReadiness.isAppReady) {
return;
}
if ([self shouldSocketBeOpen]) { if ([self shouldSocketBeOpen]) {
if (self.state != SocketManagerStateOpen) { if (self.state != SocketManagerStateOpen) {
// If we want the socket to be open and it's not open, // If we want the socket to be open and it's not open,

Loading…
Cancel
Save