@ -259,6 +259,13 @@ extension SendMediaNavigationController: UINavigationControllerDelegate {
owsFailDebug ( " unexpected navigationBar: \( navigationBar ) " )
}
}
if viewController is PhotoCaptureViewController && ! isInBatchSelectMode {
// W e ' r e e i t h e r s h o w i n g t h e c a p t u r e V i e w f o r t h e f i r s t t i m e o r t h e u s e r i s n a v i g a t i n g " b a c k "
// i n d i c a t i n g t h e y w a n t t o " r e t a k e " . W e s h o u l d d i s c a r d a n y c u r r e n t i m a g e .
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 )
}