Prevent users from selecting additional images while processing images in the image picker.

This commit is contained in:
Matthew Chen 2019-03-11 16:52:32 -04:00
parent 863c96c62a
commit 6e492927d1
1 changed files with 25 additions and 12 deletions

View File

@ -380,19 +380,32 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
}
func complete(withAssets assets: [PHAsset]) {
let attachmentPromises: [Promise<SignalAttachment>] = assets.map({
return photoCollectionContents.outgoingAttachment(for: $0)
})
firstly {
when(fulfilled: attachmentPromises)
}.map { attachments in
Logger.debug("built all attachments")
self.didComplete(withAttachments: attachments)
}.catch { error in
Logger.error("failed to prepare attachments. error: \(error)")
OWSAlerts.showAlert(title: NSLocalizedString("IMAGE_PICKER_FAILED_TO_PROCESS_ATTACHMENTS", comment: "alert title"))
}.retainUntilComplete()
ModalActivityIndicatorViewController.present(fromViewController: self,
canCancel: false) { (modal) in
let attachmentPromises: [Promise<SignalAttachment>] = assets.map({
return self.photoCollectionContents.outgoingAttachment(for: $0)
})
firstly {
when(fulfilled: attachmentPromises)
}.map { attachments in
Logger.debug("built all attachments")
DispatchQueue.main.async {
modal.dismiss(completion: {
self.didComplete(withAttachments: attachments)
})
}
}.catch { error in
Logger.error("failed to prepare attachments. error: \(error)")
DispatchQueue.main.async {
modal.dismiss(completion: {
OWSAlerts.showAlert(title: NSLocalizedString("IMAGE_PICKER_FAILED_TO_PROCESS_ATTACHMENTS", comment: "alert title"))
})
}
}.retainUntilComplete()
}
}
private func didComplete(withAttachments attachments: [SignalAttachment]) {