diff --git a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift index 60c5b38dc..46c555f2e 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift @@ -360,12 +360,15 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat func endSelectMode() { isInBatchSelectMode = false + deselectAnySelected() + } + + func deselectAnySelected() { guard let collectionView = self.collectionView else { owsFailDebug("collectionView was unexpectedly nil") return } - // deselect any selected collectionView.indexPathsForSelectedItems?.forEach { collectionView.deselectItem(at: $0, animated: false)} } @@ -447,9 +450,8 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat return } - // Iff we switched albums, discard any selection and make sure the "Select" button shows, - // not the "Done" button - endSelectMode() + // Any selections are invalid as they refer to indices in a different collection + deselectAnySelected() photoCollection = collection photoCollectionContents = photoCollection.contents()