Ignore new calls in the incomplete calls job.
This commit is contained in:
parent
4af4ca3cc5
commit
463addaa6c
|
@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
self.reportedApplicationState = UIApplicationStateInactive;
|
||||
|
||||
_appLaunchTime = [NSDate new];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(applicationWillEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSIncompleteCallsJob.h"
|
||||
#import "AppContent.h"
|
||||
#import "OWSPrimaryStorage.h"
|
||||
#import "TSCall.h"
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
|
@ -78,9 +79,17 @@ static NSString *const OWSIncompleteCallsJobCallTypeIndex = @"index_calls_on_cal
|
|||
{
|
||||
__block uint count = 0;
|
||||
|
||||
OWSAssert(CurrentAppContext().appLaunchTime);
|
||||
uint64_t cutoffTimestamp = [NSDate ows_millisecondsSince1970ForDate:CurrentAppContext().appLaunchTime];
|
||||
|
||||
[[self.primaryStorage newDatabaseConnection] readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[self
|
||||
enumerateIncompleteCallsWithBlock:^(TSCall *call) {
|
||||
if (call.timestamp <= cutoffTimestamp) {
|
||||
inc DDLogInfo(@"%@ ignoring new call: %@", self.logTag, call.uniqueId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (call.callType == RPRecentCallTypeOutgoingIncomplete) {
|
||||
DDLogDebug(@"%@ marking call as missed: %@", self.logTag, call.uniqueId);
|
||||
[call updateCallType:RPRecentCallTypeOutgoingMissed transaction:transaction];
|
||||
|
@ -99,7 +108,7 @@ static NSString *const OWSIncompleteCallsJobCallTypeIndex = @"index_calls_on_cal
|
|||
transaction:transaction];
|
||||
}];
|
||||
|
||||
DDLogDebug(@"%@ Marked %u calls as missed", self.logTag, count);
|
||||
DDLogInfo(@"%@ Marked %u calls as missed", self.logTag, count);
|
||||
}
|
||||
|
||||
#pragma mark - YapDatabaseExtension
|
||||
|
|
|
@ -91,6 +91,8 @@ NSString *NSStringForUIApplicationState(UIApplicationState value);
|
|||
// Should be a NOOP if isMainApp is NO.
|
||||
- (void)setNetworkActivityIndicatorVisible:(BOOL)value;
|
||||
|
||||
@property (atomic, readonly) NSDate *appLaunchTime;
|
||||
|
||||
@end
|
||||
|
||||
id<AppContext> CurrentAppContext(void);
|
||||
|
|
|
@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
self.reportedApplicationState = UIApplicationStateActive;
|
||||
|
||||
_appLaunchTime = [NSDate new];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(extensionHostDidBecomeActive:)
|
||||
name:NSExtensionHostDidBecomeActiveNotification
|
||||
|
|
Loading…
Reference in New Issue