Prefer "app is ready" flag to "storage is ready" flag.
This commit is contained in:
parent
be1fde905c
commit
a30170b3b2
|
@ -946,7 +946,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
|
||||
DDLogInfo(@"%@ ensureRootViewController", self.logTag);
|
||||
|
||||
if (![OWSStorage isStorageReady] || self.hasInitialRootViewController) {
|
||||
if (!AppReadiness.isAppReady || self.hasInitialRootViewController) {
|
||||
return;
|
||||
}
|
||||
self.hasInitialRootViewController = YES;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#import "OWSBatchMessageProcessor.h"
|
||||
#import "AppContext.h"
|
||||
#import "AppReadiness.h"
|
||||
#import "NSArray+OWS.h"
|
||||
#import "OWSBackgroundTask.h"
|
||||
#import "OWSMessageManager.h"
|
||||
|
@ -262,8 +263,8 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
|||
_isDrainingQueue = NO;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(storageIsReady)
|
||||
name:StorageIsReadyNotification
|
||||
selector:@selector(appIsReady)
|
||||
name:AppIsReadyNotification
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
|
@ -274,7 +275,7 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)storageIsReady
|
||||
- (void)appIsReady
|
||||
{
|
||||
[self drainQueue];
|
||||
}
|
||||
|
@ -307,7 +308,7 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
|||
}
|
||||
|
||||
dispatch_async(self.serialQueue, ^{
|
||||
if (![OWSStorage isStorageReady]) {
|
||||
if (!AppReadiness.isAppReady) {
|
||||
// We don't want to process incoming messages until storage is ready.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#import "OWSMessageReceiver.h"
|
||||
#import "AppContext.h"
|
||||
#import "AppReadiness.h"
|
||||
#import "NSArray+OWS.h"
|
||||
#import "OWSBackgroundTask.h"
|
||||
#import "OWSBatchMessageProcessor.h"
|
||||
|
@ -242,8 +243,8 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
|||
_isDrainingQueue = NO;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(storageIsReady)
|
||||
name:StorageIsReadyNotification
|
||||
selector:@selector(appIsReady)
|
||||
name:AppIsReadyNotification
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
|
@ -254,7 +255,7 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)storageIsReady
|
||||
- (void)appIsReady
|
||||
{
|
||||
[self drainQueue];
|
||||
}
|
||||
|
@ -284,7 +285,7 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
|||
}
|
||||
|
||||
dispatch_async(self.serialQueue, ^{
|
||||
if (![OWSStorage isStorageReady]) {
|
||||
if (!AppReadiness.isAppReady) {
|
||||
// We don't want to process incoming messages until storage is ready.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSReadReceiptManager.h"
|
||||
#import "AppReadiness.h"
|
||||
#import "NSNotificationCenter+OWS.h"
|
||||
#import "OWSLinkedDeviceReadReceipt.h"
|
||||
#import "OWSMessageSender.h"
|
||||
|
@ -177,8 +178,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
OWSSingletonAssert();
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(storageIsReady)
|
||||
name:StorageIsReadyNotification
|
||||
selector:@selector(appIsReady)
|
||||
name:AppIsReadyNotification
|
||||
object:nil];
|
||||
|
||||
// Try to start processing.
|
||||
|
@ -192,7 +193,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)storageIsReady
|
||||
- (void)appIsReady
|
||||
{
|
||||
[self scheduleProcessing];
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
@synchronized(self)
|
||||
{
|
||||
if (![OWSStorage isStorageReady]) {
|
||||
if (!AppReadiness.isAppReady) {
|
||||
DDLogInfo(@"%@ Deferring read receipt processing; storage not yet ready.", self.logTag);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const AppIsReadyNotification;
|
||||
|
||||
typedef void (^AppReadyBlock)(void);
|
||||
|
||||
@interface AppReadiness : NSObject
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
//
|
||||
|
||||
#import "AppReadiness.h"
|
||||
#import "NSNotificationCenter+OWS.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSString *const AppIsReadyNotification = @"AppIsReadyNotification";
|
||||
|
||||
@interface AppReadiness ()
|
||||
|
||||
@property (atomic) BOOL isAppReady;
|
||||
|
@ -82,6 +85,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.isAppReady = YES;
|
||||
|
||||
[self runAppReadyBlocks];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:AppIsReadyNotification object:nil userInfo:nil];
|
||||
}
|
||||
|
||||
- (void)runAppReadyBlocks
|
||||
|
|
|
@ -282,7 +282,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
|
|||
private func ensureRootViewController() {
|
||||
Logger.debug("\(self.logTag) \(#function)")
|
||||
|
||||
guard OWSStorage.isStorageReady() else {
|
||||
guard AppReadiness.isAppReady() else {
|
||||
return
|
||||
}
|
||||
guard !hasInitialRootViewController else {
|
||||
|
|
Loading…
Reference in New Issue