Skip to content

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

dont ask for password when sending to own server

rorycleard1cf0962f392
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index 2276e77..fc05c18 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -401,6 +401,8 @@
sendNotifSwitch.on = isPremium ? self.sendNotifEnabled : NO;
[sendNotifSwitch addTarget:self action:@selector(sendNotifSwitchToggled:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = sendNotifSwitch;
+
+ // Only disable switch if not premium; otherwise, keep it enabled
sendNotifSwitch.enabled = isPremium;
cell.textLabel.textColor = isPremium ? [UIColor labelColor] : [UIColor grayColor];
cell.userInteractionEnabled = YES;
@@ -633,11 +635,14 @@
- (void)useOwnnotificationServerSwitchToggled:(UISwitch *)sender {
self.useOwnServerEnabled = sender.on;
self.isnotificationServerSectionExpanded = sender.on;
-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:self.useOwnServerEnabled forKey:@"use_own_server_enabled"];
[defaults synchronize];
-
+ if (!self.useOwnServerEnabled && ![self retrievePasswordFromSecretsManager]) {
+ self.sendNotifEnabled = NO;
+ [defaults setBool:NO forKey:@"send_notif_enabled"];
+ [defaults synchronize];
+ }
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
}
@@ -694,27 +699,34 @@
}
if (sender.on) {
- NSString *password = [self retrievePasswordFromSecretsManager];
- if (!password) {
- [self promptForPasswordWithCompletion:^(BOOL success) {
- if (success) {
- self.sendNotifEnabled = YES;
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"send_notif_enabled"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- } else {
- sender.on = NO;
- }
- }];
- } else {
+ if (self.useOwnServerEnabled) {
self.sendNotifEnabled = YES;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"send_notif_enabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
+ } else {
+ NSString *password = [self retrievePasswordFromSecretsManager];
+ if (!password) {
+ [self promptForPasswordWithCompletion:^(BOOL success) {
+ if (success) {
+ self.sendNotifEnabled = YES;
+ [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"send_notif_enabled"];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ } else {
+ sender.on = NO;
+ }
+ }];
+ } else {
+ self.sendNotifEnabled = YES;
+ [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"send_notif_enabled"];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ }
}
} else {
self.sendNotifEnabled = NO;
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"send_notif_enabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
+ [self.tableView reloadData];
}
- (void)promptForPasswordWithCompletion:(void (^)(BOOL success))completion {
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index 16b9dc4..518c41c 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -587,7 +587,6 @@ NSMutableDictionary *classColorMap;
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.previewLayer.frame = self.view.bounds;
- UIDeviceOrientation currentOrientation = [self getCurrentOrientation];
[self updateButtonFrames];
}