diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index a40058dad..85d6277b3 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -730,18 +730,21 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex [cancelButtonWrapper addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelButtonWrapperTapped:)]]; - UIView *_Nullable cancelButtonSuperview = [self.attachmentView contentView]; - if (cancelButtonSuperview) { - cancelButtonSuperview.layer.borderColor = self.inputTextView.layer.borderColor; - cancelButtonSuperview.layer.borderWidth = self.inputTextView.layer.borderWidth; - cancelButtonSuperview.layer.cornerRadius = self.inputTextView.layer.cornerRadius; - cancelButtonSuperview.clipsToBounds = YES; + UIView *_Nullable attachmentContentView = [self.attachmentView contentView]; + // Place the cancel button inside the attachment view's content area, + // if possible. If not, just place it inside the attachment view. + UIView *cancelButtonReferenceView = attachmentContentView; + if (attachmentContentView) { + attachmentContentView.layer.borderColor = self.inputTextView.layer.borderColor; + attachmentContentView.layer.borderWidth = self.inputTextView.layer.borderWidth; + attachmentContentView.layer.cornerRadius = self.inputTextView.layer.cornerRadius; + attachmentContentView.clipsToBounds = YES; } else { - cancelButtonSuperview = self.attachmentView; + cancelButtonReferenceView = self.attachmentView; } - [cancelButtonSuperview addSubview:cancelButtonWrapper]; - [cancelButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop]; - [cancelButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeRight]; + [self.contentView addSubview:cancelButtonWrapper]; + [cancelButtonWrapper autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:cancelButtonReferenceView]; + [cancelButtonWrapper autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:cancelButtonReferenceView]; UIImage *cancelIcon = [UIImage imageNamed:@"cancel-cross-white"]; OWSAssert(cancelIcon); diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index bc8afeff2..00d7189dd 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2318,15 +2318,13 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { #pragma mark GifPickerViewControllerDelegate -- (void)gifPickerWillSend +- (void)gifPickerDidSelectWithAttachment:(SignalAttachment *)attachment { - [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; -} + OWSAssert(attachment); -- (void)gifPickerDidSendWithOutgoingMessage:(TSOutgoingMessage *)message -{ - [self messageWasSent:message]; + [self tryToSendAttachmentIfApproved:attachment]; + [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; [self ensureDynamicInteractions]; } diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift index 07da5294d..0ce0b91a5 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift @@ -6,8 +6,7 @@ import Foundation @objc protocol GifPickerViewControllerDelegate: class { - func gifPickerWillSend() - func gifPickerDidSend(outgoingMessage: TSOutgoingMessage) + func gifPickerDidSelect(attachment: SignalAttachment) } class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegate, GifPickerLayoutDelegate { @@ -359,11 +358,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect } let attachment = SignalAttachment(dataSource: dataSource, dataUTI: asset.rendition.utiType) - strongSelf.delegate?.gifPickerWillSend() - - let outgoingMessage = ThreadUtil.sendMessage(with: attachment, in: strongSelf.thread, messageSender: strongSelf.messageSender) - - strongSelf.delegate?.gifPickerDidSend(outgoingMessage: outgoingMessage) + strongSelf.delegate?.gifPickerDidSelect(attachment: attachment) strongSelf.dismiss(animated: true, completion: nil) }.catch { [weak self] error in