From 6e41826b15f73259529d423bcbeabba260d4e048 Mon Sep 17 00:00:00 2001 From: natecraft1 Date: Wed, 2 Dec 2020 21:04:11 -0800 Subject: [PATCH 1/2] change fetchResults from a var to a function --- Sources/Model/Settings.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Model/Settings.swift b/Sources/Model/Settings.swift index 5ff8b351..a1fcd2b5 100755 --- a/Sources/Model/Settings.swift +++ b/Sources/Model/Settings.swift @@ -119,9 +119,11 @@ import Photos /// PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumSelfPortraits, options: options), /// PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumPanoramas, options: options), /// PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumVideos, options: options), - public lazy var fetchResults: [PHFetchResult] = [ - PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: options), - ] + public lazy var fetchResults: () -> [PHFetchResult] = { [options] in + return [ + PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: options), + ] + } } @objc(BSImagePickerAssets) From 7dda23707c58a26b762c761804dc170c66b3e9b4 Mon Sep 17 00:00:00 2001 From: natecraft1 Date: Wed, 2 Dec 2020 21:05:12 -0800 Subject: [PATCH 2/2] call fetchResults as a function --- Sources/Controller/ImagePickerController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Controller/ImagePickerController.swift b/Sources/Controller/ImagePickerController.swift index 85b086de..d1e28790 100644 --- a/Sources/Controller/ImagePickerController.swift +++ b/Sources/Controller/ImagePickerController.swift @@ -64,7 +64,7 @@ import Photos let fetchOptions = settings.fetch.assets.options.copy() as! PHFetchOptions fetchOptions.fetchLimit = 1 - return settings.fetch.album.fetchResults.filter { + return settings.fetch.album.fetchResults().filter { $0.count > 0 }.flatMap { $0.objects(at: IndexSet(integersIn: 0..<$0.count))