Modify views to observe changes when active, not just foreground.

pull/1/head
Matthew Chen 7 years ago
parent 812210a63c
commit fefc9843b1

@ -4441,7 +4441,7 @@ typedef enum : NSUInteger {
- (void)updateShouldObserveDBModifications - (void)updateShouldObserveDBModifications
{ {
BOOL isAppForegroundAndActive = CurrentAppContext().reportedApplicationState == UIApplicationStateActive; BOOL isAppForegroundAndActive = CurrentAppContext().isAppForegroundAndActive;
self.shouldObserveDBModifications = self.isViewVisible && isAppForegroundAndActive; self.shouldObserveDBModifications = self.isViewVisible && isAppForegroundAndActive;
} }

@ -485,7 +485,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)updateShouldObserveDBModifications - (void)updateShouldObserveDBModifications
{ {
BOOL isAppForegroundAndActive = CurrentAppContext().reportedApplicationState == UIApplicationStateActive; BOOL isAppForegroundAndActive = CurrentAppContext().isAppForegroundAndActive;
self.shouldObserveDBModifications = self.isViewVisible && isAppForegroundAndActive; self.shouldObserveDBModifications = self.isViewVisible && isAppForegroundAndActive;
} }

@ -156,6 +156,11 @@ NS_ASSUME_NONNULL_BEGIN
return self.reportedApplicationState == UIApplicationStateBackground; return self.reportedApplicationState == UIApplicationStateBackground;
} }
- (BOOL)isAppForegroundAndActive
{
return self.reportedApplicationState == UIApplicationStateActive;
}
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler: - (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
(BackgroundTaskExpirationHandler)expirationHandler (BackgroundTaskExpirationHandler)expirationHandler
{ {

@ -79,8 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateShouldObserveDBModifications - (void)updateShouldObserveDBModifications
{ {
BOOL isAppForegroundAndActive = CurrentAppContext().reportedApplicationState == UIApplicationStateActive; self.shouldObserveDBModifications = CurrentAppContext().isAppForegroundAndActive;
self.shouldObserveDBModifications = isAppForegroundAndActive;
} }
// Don't observe database change notifications when the app is in the background. // Don't observe database change notifications when the app is in the background.

@ -55,6 +55,11 @@ NSString *NSStringForUIApplicationState(UIApplicationState value);
// This method is thread-safe. // This method is thread-safe.
- (BOOL)isInBackground; - (BOOL)isInBackground;
// A convenience accessor for reportedApplicationState.
//
// This method is thread-safe.
- (BOOL)isAppForegroundAndActive;
// Should start a background task if isMainApp is YES. // Should start a background task if isMainApp is YES.
// Should just return UIBackgroundTaskInvalid if isMainApp is NO. // Should just return UIBackgroundTaskInvalid if isMainApp is NO.
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler: - (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:

@ -151,6 +151,11 @@ NS_ASSUME_NONNULL_BEGIN
return self.reportedApplicationState == UIApplicationStateBackground; return self.reportedApplicationState == UIApplicationStateBackground;
} }
- (BOOL)isAppForegroundAndActive
{
return self.reportedApplicationState == UIApplicationStateActive;
}
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler: - (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
(BackgroundTaskExpirationHandler)expirationHandler (BackgroundTaskExpirationHandler)expirationHandler
{ {

Loading…
Cancel
Save