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

pull/2/head
Matthew Chen 6 years ago
parent 863c96c62a
commit 6e492927d1

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

Loading…
Cancel
Save