From f8e073f09afdafa2a365ab7dc80d22e8965381de Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 4 Dec 2018 08:01:24 -0500 Subject: [PATCH] enforce attachment limit in photo picker --- .../PhotoLibrary/ImagePickerController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift index 0d34b5687..e333fd8d7 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift @@ -387,6 +387,14 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat // MARK: - UICollectionView + override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + guard let indexPathsForSelectedItems = collectionView.indexPathsForSelectedItems else { + return true + } + + return indexPathsForSelectedItems.count < SignalAttachment.maxAttachmentsAllowed + } + override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let asset = photoCollectionContents.asset(at: indexPath.item)