per design: "back" is retake for first photo

This commit is contained in:
Michael Kirk 2019-04-13 10:52:29 -06:00
parent 26ef36dc55
commit db410becb7

View file

@ -259,6 +259,13 @@ extension SendMediaNavigationController: UINavigationControllerDelegate {
owsFailDebug("unexpected navigationBar: \(navigationBar)")
}
}
if viewController is PhotoCaptureViewController && !isInBatchSelectMode {
// We're either showing the captureView for the first time or the user is navigating "back"
// indicating they want to "retake". We should discard any current image.
discardCameraDraft()
}
self.updateButtons(topViewController: viewController)
}
@ -305,6 +312,14 @@ extension SendMediaNavigationController: PhotoCaptureViewControllerDelegate {
let dontAbandonText = NSLocalizedString("SEND_MEDIA_RETURN_TO_CAMERA", comment: "alert action when the user decides not to cancel the media flow after all.")
didRequestExit(dontAbandonText: dontAbandonText)
}
func discardCameraDraft() {
assert(attachmentDraftCollection.cameraAttachments.count <= 1)
if let lastCameraAttachment = attachmentDraftCollection.cameraAttachments.last {
attachmentDraftCollection.remove(attachment: lastCameraAttachment)
}
assert(attachmentDraftCollection.cameraAttachments.count == 0)
}
}
extension SendMediaNavigationController: ImagePickerGridControllerDelegate {
@ -457,6 +472,17 @@ private struct AttachmentDraftCollection {
}
}
var cameraAttachments: [SignalAttachment] {
return attachmentDrafts.compactMap { attachmentDraft in
switch attachmentDraft.source {
case .picker:
return nil
case .camera(let cameraAttachment):
return cameraAttachment
}
}
}
mutating func append(_ element: AttachmentDraft) {
attachmentDrafts.append(element)
}