Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

fix null session bug

roryclear22fda7486432
diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.m
index f67de94..1049e93 100644
--- a/clearcam/GalleryViewController.m
+++ b/clearcam/GalleryViewController.m
@@ -301,12 +301,14 @@
if (self.isLoadingVideos) return;
self.isLoadingVideos = YES;
-
+
NSURLComponents *components = [NSURLComponents componentsWithString:@"https://rors.ai/events"];
- NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];
+ __block NSString *sessionToken = @"";
+ [[StoreManager sharedInstance] verifySubscriptionWithCompletionIfSubbed:^(BOOL isActive, NSDate *expiryDate) {
+ sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];
+ }];
NSMutableArray<NSURLQueryItem *> *queryItems = [NSMutableArray array];
-
if (sessionToken) [queryItems addObject:[NSURLQueryItem queryItemWithName:@"session_token" value:sessionToken]];
NSDate *latestDate = [self latestDownloadedFileDate];
diff --git a/clearcam/StoreManager.m b/clearcam/StoreManager.m
index 3977610..fe8e6f9 100644
--- a/clearcam/StoreManager.m
+++ b/clearcam/StoreManager.m
@@ -230,8 +230,8 @@ NSString *const StoreManagerSubscriptionStatusDidChangeNotification = @"StoreMan
NSDate *expiry = [[NSUserDefaults standardUserDefaults] objectForKey:@"expiry"];
BOOL isSubscribed = [[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"];
BOOL sessionExpiredOrNow = !expiry || [expiry compare:[NSDate date]] != NSOrderedDescending;
- if (isSubscribed || [StoreManager sharedInstance].last_check_time || [[NSDate date] timeIntervalSince1970] - [StoreManager sharedInstance].last_check_time > 120.0) {
- if (sessionExpiredOrNow) {
+ if (isSubscribed || [StoreManager sharedInstance].last_check_time || [[NSDate date] timeIntervalSince1970] - [StoreManager sharedInstance].last_check_time > 120.0 || ![[StoreManager sharedInstance] retrieveSessionTokenFromKeychain]) {
+ if (sessionExpiredOrNow || ![[StoreManager sharedInstance] retrieveSessionTokenFromKeychain]) {
[self verifySubscriptionWithCompletion:^(BOOL isActive, NSDate *expiryDate) {
if (completion) {
completion(isActive, expiryDate);
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index 27ca893..be47576 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -755,7 +755,6 @@ NSMutableDictionary *classColorMap;
- (void)finishRecording {
- NSLog(@"rory finish recording %ld %@", (long)[FileServer sharedInstance].segment_length, self.isStreaming ? @"YES" : @"NO");
if (!(self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting)) return;
NSString *segmentsDirectory = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:self.dayFolderName];