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

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

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

Loading…
Cancel
Save