feat: add screen recordings filter, exclude by default
Screen recordings are videos captured by iOS screen recording and are almost never wanted in a photo backup. They are now excluded from all counts and backup queues unless explicitly enabled. Changes: - BackupFilter.includeScreenRecordings (default: false) added - PHAssetMediaSubtype.videoScreenRecording predicate applied in both fetchAssets() and fetchResultForReconciliation() — excluded at the PHFetchRequest level before enumeration - LocalPhotoIndex.Record.isScreenRecording populated via makeRecord() so the fast-path countSafe/count also respects the toggle - LocalPhotoIndex.passes() checks includeScreenRecordings - Settings "Screen Recordings" toggle added below Screenshots This also resolves the transient count flash: screen recordings were being included in the "need backup" tally on the initial fast-path reconcile, then dropping when the filter was fully applied. Co-Authored-By: Kutesir <kutesir@provoc.ug> Co-Authored-By: Sentry <sentry@provoc.ug>
This commit is contained in:
@@ -34,6 +34,12 @@ final class PhotoLibraryService: PhotoLibraryProtocol {
|
||||
PHAssetMediaSubtype.photoScreenshot.rawValue
|
||||
))
|
||||
}
|
||||
if !filter.includeScreenRecordings {
|
||||
subpredicates.append(NSPredicate(
|
||||
format: "NOT ((mediaSubtype & %d) != 0)",
|
||||
PHAssetMediaSubtype.videoScreenRecording.rawValue
|
||||
))
|
||||
}
|
||||
|
||||
if subpredicates.count > 1 {
|
||||
options.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: subpredicates)
|
||||
@@ -46,6 +52,7 @@ final class PhotoLibraryService: PhotoLibraryProtocol {
|
||||
result.enumerateObjects { asset, _, _ in
|
||||
autoreleasepool {
|
||||
let isScreenshot = asset.mediaSubtypes.contains(.photoScreenshot)
|
||||
let isScreenRecording = asset.mediaSubtypes.contains(.videoScreenRecording)
|
||||
let resources = PHAssetResource.assetResources(for: asset)
|
||||
let isRAW = resources.contains { $0.type == .alternatePhoto }
|
||||
if isRAW && !filter.includeRAW { return }
|
||||
@@ -61,7 +68,8 @@ final class PhotoLibraryService: PhotoLibraryProtocol {
|
||||
pixelHeight: asset.pixelHeight,
|
||||
duration: asset.duration,
|
||||
isScreenshot: isScreenshot,
|
||||
isRAW: isRAW
|
||||
isRAW: isRAW,
|
||||
isScreenRecording: isScreenRecording
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -91,6 +99,12 @@ final class PhotoLibraryService: PhotoLibraryProtocol {
|
||||
PHAssetMediaSubtype.photoScreenshot.rawValue
|
||||
))
|
||||
}
|
||||
if !filter.includeScreenRecordings {
|
||||
subpredicates.append(NSPredicate(
|
||||
format: "NOT ((mediaSubtype & %d) != 0)",
|
||||
PHAssetMediaSubtype.videoScreenRecording.rawValue
|
||||
))
|
||||
}
|
||||
|
||||
if subpredicates.count > 1 {
|
||||
options.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: subpredicates)
|
||||
|
||||
Reference in New Issue
Block a user