]> git.r.bdr.sh - rbdr/captura/blobdiff - Captura/Data/CapturaSettings.swift
Adds configure support for URLs
[rbdr/captura] / Captura / Data / CapturaSettings.swift
index 85368ea0695240404ce303ef403f6ccd82bed62e..578d17c2a4b498f7e8a231d4e785f22be280678c 100644 (file)
@@ -3,7 +3,11 @@ import Foundation
 struct CapturaSettings {
   static var frameRate: Int {
     get {
-      UserDefaults.standard.integer(forKey: "frameRate")
+      if UserDefaults.standard.object(forKey: "frameRate") == nil {
+        return 10
+      } else {
+        return min(10, max(4, UserDefaults.standard.integer(forKey: "frameRate")))
+      }
     }
     set {
       UserDefaults.standard.setValue(newValue, forKey: "frameRate")
@@ -62,7 +66,11 @@ struct CapturaSettings {
   
   static var shouldKeepLocalFiles: Bool {
     get {
-      UserDefaults.standard.bool(forKey: "keepFiles")
+      if UserDefaults.standard.object(forKey: "keepFiles") == nil {
+        return true
+      } else {
+        return UserDefaults.standard.bool(forKey: "keepFiles")
+      }
     }
     set {
       UserDefaults.standard.set(newValue, forKey: "keepFiles")
@@ -70,7 +78,12 @@ struct CapturaSettings {
   }
   
   static var shouldAllowURLAutomation: Bool {
-    UserDefaults.standard.bool(forKey: "allowURLAutomation")
+    get {
+      UserDefaults.standard.bool(forKey: "allowURLAutomation")
+    }
+    set {
+      UserDefaults.standard.setValue(newValue, forKey: "allowURLAutomation")
+    }
   }
   
   static func apply(_ config: ConfigureAction) {