mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-03-19 22:03:56 +00:00
Adding a safeguard to startNewSessionIfNeeded and removing safeguard that never helped anyone as appBackgroundTimeBeforeSessionExpires is always 20!
This commit is contained in:
@@ -122,15 +122,12 @@ static NSString *const BITMetricsURLPathString = @"v2/track";
|
||||
}
|
||||
|
||||
- (void)startNewSessionIfNeeded {
|
||||
if (self.appBackgroundTimeBeforeSessionExpires == 0) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
dispatch_async(_metricsEventQueue, ^{
|
||||
typeof(self) strongSelf = weakSelf;
|
||||
[strongSelf startNewSessionWithId:bit_UUID()];
|
||||
});
|
||||
}
|
||||
|
||||
double appDidEnterBackgroundTime = [self.userDefaults doubleForKey:kBITApplicationDidEnterBackgroundTime];
|
||||
// Add safeguard in case this returns a negative value
|
||||
if(appDidEnterBackgroundTime < 0) {
|
||||
appDidEnterBackgroundTime = 0;
|
||||
[self.userDefaults setDouble:0 forKey:kBITApplicationDidEnterBackgroundTime];
|
||||
}
|
||||
double timeSinceLastBackground = [[NSDate date] timeIntervalSince1970] - appDidEnterBackgroundTime;
|
||||
if (timeSinceLastBackground > self.appBackgroundTimeBeforeSessionExpires) {
|
||||
[self startNewSessionWithId:bit_UUID()];
|
||||
|
||||
Reference in New Issue
Block a user