From 066b400590634d319a1c5e32765e583d65527bac Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 18 Jan 2019 10:34:11 -0700 Subject: [PATCH] Honor selection with "Add More" --- .../PhotoLibrary/ImagePickerController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift index 3e99aab4a..d3e0ad59d 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift @@ -579,6 +579,23 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat // If we re-enter image picking via "add more" button, do so in batch mode. isInBatchSelectMode = true + // clear selection + deselectAnySelected() + + // removing-and-readding accomplishes two things + // 1. respect items removed from the rail while in the approval view + // 2. in the case of the user adding more to what was a single item + // which was not selected in batch mode, ensure that item is now + // part of the "batch selection" + for previouslySelected in attachments { + guard let assetId = previouslySelected.assetId else { + owsFailDebug("assetId was unexpectedly nil") + continue + } + + selectedIds.add(assetId as Any) + } + navigationController?.popToViewController(self, animated: true) }