diff --git a/Signal/src/ViewControllers/PhotoLibrary/PhotoLibrary.swift b/Signal/src/ViewControllers/PhotoLibrary/PhotoLibrary.swift index d510e5a3a..86a45d86d 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/PhotoLibrary.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/PhotoLibrary.swift @@ -288,11 +288,24 @@ class PhotoLibrary: NSObject, PHPhotoLibraryChangeObserver { guard photoCollection.contents().assetCount > 0 else { return } + collections.append(photoCollection) } let processPHAssetCollections: (PHFetchResult) -> Void = { (fetchResult) in - for index in 0..) -> Void = { (fetchResult) in @@ -302,13 +315,19 @@ class PhotoLibrary: NSObject, PHPhotoLibraryChangeObserver { } let fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key: "endDate", ascending: true)] + // Try to add "Camera Roll" first. processPHAssetCollections(PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: fetchOptions)) - // User-created albums. - processPHCollections(PHAssetCollection.fetchTopLevelUserCollections(with: fetchOptions)) + + // Favorites + processPHAssetCollections(PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumFavorites, options: fetchOptions)) + // Smart albums. processPHAssetCollections(PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumRegular, options: fetchOptions)) + // User-created albums. + processPHCollections(PHAssetCollection.fetchTopLevelUserCollections(with: fetchOptions)) + return collections } }