From e1e1e51723ea760b84d1b6cc337c1c823d83aaf5 Mon Sep 17 00:00:00 2001 From: Jedidiah Laudenslayer Date: Tue, 7 May 2024 09:14:03 -0400 Subject: [PATCH] Added count property that reflect actual asset count Change-Id: I7a377ff53592200ba916b22319c6ca5c35cddea7 --- TLPhotoPicker/Classes/TLAssetsCollection.swift | 5 +++++ TLPhotoPicker/Classes/TLPhotosPickerViewController.swift | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TLPhotoPicker/Classes/TLAssetsCollection.swift b/TLPhotoPicker/Classes/TLAssetsCollection.swift index 7758e44e..be48d4e7 100644 --- a/TLPhotoPicker/Classes/TLAssetsCollection.swift +++ b/TLPhotoPicker/Classes/TLAssetsCollection.swift @@ -358,6 +358,11 @@ public struct TLAssetsCollection { return count + (self.useCameraButton ? 1 : 0) } } + var assetCount: Int { + get { + return self.fetchResult?.count ?? 0 + } + } init(collection: PHAssetCollection) { self.phAssetCollection = collection diff --git a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift index 966b32aa..f301e399 100644 --- a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift +++ b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift @@ -611,7 +611,7 @@ extension TLPhotosPickerViewController: TLPhotoLibraryDelegate { func loadCompleteAllCollection(collections: [TLAssetsCollection]) { self.collections = collections self.focusFirstCollection() - let isEmpty = !self.collections.contains(where: { $0.count > 0 }) + let isEmpty = !self.collections.contains(where: { $0.assetCount > 0 }) self.subTitleStackView.isHidden = isEmpty self.emptyView.isHidden = !isEmpty self.emptyImageView.isHidden = self.emptyImageView.image == nil