diff --git a/iOSClient/Data/NCManageDatabase+Account.swift b/iOSClient/Data/NCManageDatabase+Account.swift index 91038bee94..e4db45b92e 100644 --- a/iOSClient/Data/NCManageDatabase+Account.swift +++ b/iOSClient/Data/NCManageDatabase+Account.swift @@ -38,6 +38,7 @@ class tableAccount: Object, NCUserBaseUrl { @objc dynamic var autoUploadFull: Bool = false @objc dynamic var autoUploadImage: Bool = false @objc dynamic var autoUploadVideo: Bool = false + @objc dynamic var autoUploadFavoritesOnly: Bool = false @objc dynamic var autoUploadWWAnPhoto: Bool = false @objc dynamic var autoUploadWWAnVideo: Bool = false @objc dynamic var backend = "" diff --git a/iOSClient/Networking/NCAutoUpload.swift b/iOSClient/Networking/NCAutoUpload.swift index fd4bf4062e..9fd04960c7 100644 --- a/iOSClient/Networking/NCAutoUpload.swift +++ b/iOSClient/Networking/NCAutoUpload.swift @@ -227,12 +227,16 @@ class NCAutoUpload: NSObject { } let idAsset = account.account + asset.localIdentifier + creationDateString if !(idAssets?.contains(idAsset) ?? false) { - newAssets.append(asset) + if ((asset.isFavorite && account.autoUploadFavoritesOnly) || !account.autoUploadFavoritesOnly) { + newAssets.append(asset) + } } } } else { assets.enumerateObjects { asset, _, _ in - newAssets.append(asset) + if ((asset.isFavorite && account.autoUploadFavoritesOnly) || !account.autoUploadFavoritesOnly) { + newAssets.append(asset) + } } } completion(newAssets) diff --git a/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift b/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift index ed14ca4ade..7bd3fc80f3 100644 --- a/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift +++ b/iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift @@ -42,6 +42,8 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling { @Published var autoUploadVideo: Bool = false /// A state variable that indicates whether auto upload for videos is enabled or not @Published var autoUploadWWAnVideo: Bool = false + /// A state variable that indicates whether only assets marked as favorites should be uploaded + @Published var autoUploadFavoritesOnly: Bool = false /// A state variable that indicates whether auto upload for full resolution photos is enabled or not @Published var autoUploadFull: Bool = false /// A state variable that indicates whether auto upload creates subfolders based on date or not @@ -149,6 +151,10 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling { func handleAutoUploadWWAnVideoChange(newValue: Bool) { updateAccountProperty(\.autoUploadWWAnVideo, value: newValue) } + + func handleAutoUploadFavoritesOnlyChange(newValue: Bool) { + updateAccountProperty(\.autoUploadFavoritesOnly, value: newValue) + } /// Updates the auto-upload full content setting. func handleAutoUploadFullChange(newValue: Bool) { diff --git a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift index 17f5497a13..606daeb186 100644 --- a/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift +++ b/iOSClient/Settings/AutoUpload/NCAutoUploadView.swift @@ -113,6 +113,15 @@ struct NCAutoUploadView: View { } .font(.system(size: 16)) }) + /// Only upload favorites if desired + Section(content: { + Toggle(NSLocalizedString("_autoupload_favorites_", comment: ""), isOn: $model.autoUploadFavoritesOnly) + .tint(Color(NCBrandColor.shared.brandElement)) + .onChange(of: model.autoUploadFavoritesOnly) { newValue in + model.handleAutoUploadFavoritesOnlyChange(newValue: newValue) + } + .font(.system(size: 16)) + }) /// Auto Upload create subfolder Section(content: { Toggle(NSLocalizedString("_autoupload_create_subfolder_", comment: ""), isOn: $model.autoUploadCreateSubfolder) diff --git a/iOSClient/Supporting Files/de.lproj/Localizable.strings b/iOSClient/Supporting Files/de.lproj/Localizable.strings index ece2e399b5..db9ce32bd8 100644 Binary files a/iOSClient/Supporting Files/de.lproj/Localizable.strings and b/iOSClient/Supporting Files/de.lproj/Localizable.strings differ diff --git a/iOSClient/Supporting Files/en.lproj/Localizable.strings b/iOSClient/Supporting Files/en.lproj/Localizable.strings index 9f5aed61d0..aa810fe5af 100644 --- a/iOSClient/Supporting Files/en.lproj/Localizable.strings +++ b/iOSClient/Supporting Files/en.lproj/Localizable.strings @@ -390,6 +390,7 @@ "_autoupload_background_" = "Auto upload in the background"; "_autoupload_photos_" = "Auto upload photos"; "_autoupload_videos_" = "Auto upload videos"; +"_autoupload_favorites_" = "Upload favorites only"; "_autoupload_description_" = "New photos/videos will be automatically uploaded to your server."; "_autoupload_description_background_" = "This option requires the use of GPS to trigger the detection of new photos/videos in the camera roll once the location changes significantly"; "_autoupload_background_title_" = "Limitations";