]> git.r.bdr.sh - rbdr/captura/blobdiff - Captura/Data/CapturaSettings.swift
Complete initial release
[rbdr/captura] / Captura / Data / CapturaSettings.swift
index d0d04f2506c3c851afc2e8620fc08fa64150c909..01ef78c56bf222a1ec2f960e284cff28134094e9 100644 (file)
@@ -10,20 +10,37 @@ struct CapturaSettings {
   }
   
   static var shouldSaveMp4: Bool {
-    outputFormats.shouldSaveMp4()
+    outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4)
   }
   
   static var shouldSaveGif: Bool {
-    outputFormats.shouldSaveGif()
+    outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif)
   }
   
+  static var shouldUploadGif: Bool {
+    backendFormat.shouldSaveGif()
+  }
   
-  static var shouldSendNotifications: Bool {
-    get {
-      UserDefaults.standard.bool(forKey: "shouldSendNotifications")
-    }
-    set {
-      UserDefaults.standard.setValue(newValue, forKey: "shouldSendNotifications")
+  static var shouldUploadMp4: Bool {
+    backendFormat.shouldSaveMp4()
+  }
+  
+  static var shouldUseBackend: Bool {
+    backend != nil
+  }
+  
+  static var backend: URL? {
+    if let url = UserDefaults.standard.string(forKey: "backendUrl") {
+      return URL(string: url)
     }
+    return nil
+  }
+  
+  static var backendFormat: OutputFormatSetting {
+    OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .all
+  }
+  
+  static var shouldKeepLocalFiles: Bool {
+    UserDefaults.standard.bool(forKey: "keepFiles")
   }
 }