Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Source/AssetManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ open class AssetManager {
public static func fetch(withConfiguration configuration: ImagePickerConfiguration, _ completion: @escaping (_ assets: [PHAsset]) -> Void) {
guard PHPhotoLibrary.authorizationStatus() == .authorized else { return }

let options = PHFetchOptions()
options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]

DispatchQueue.global(qos: .background).async {
let fetchResult = configuration.allowVideoSelection
? PHAsset.fetchAssets(with: PHFetchOptions())
: PHAsset.fetchAssets(with: .image, options: PHFetchOptions())
? PHAsset.fetchAssets(with: options)
: PHAsset.fetchAssets(with: .image, options: options)

if fetchResult.count > 0 {
var assets = [PHAsset]()
Expand Down