Respond to CR.

This commit is contained in:
Matthew Chen 2018-04-06 12:34:50 -04:00
parent 7067085cdd
commit 316b55bf9d
3 changed files with 27 additions and 27 deletions

View file

@ -22,7 +22,7 @@ typedef NS_ENUM(NSUInteger, OWSMessageGestureLocation) {
@property (nonatomic) NSCache *cellMediaCache;
@property (nonatomic, nullable, readonly) UIView *lastBodyMediaView;
@property (nonatomic, nullable, readonly) UIView *bodyMediaView;
- (instancetype)init NS_UNAVAILABLE;

View file

@ -23,9 +23,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) OWSMessageTextView *bodyTextView;
@property (nonatomic, nullable) UIView *lastQuotedMessageView;
@property (nonatomic, nullable) UIView *quotedMessageView;
@property (nonatomic, nullable) UIView *lastBodyMediaView;
@property (nonatomic, nullable) UIView *bodyMediaView;
// Should lazy-load expensive view contents (images, etc.).
// Should do nothing if view is already loaded.
@ -255,7 +255,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSQuotedMessageView *quotedMessageView = [OWSQuotedMessageView
quotedMessageViewForConversation:message.quotedMessage
displayableQuotedText:(self.viewItem.hasQuotedText ? self.viewItem.displayableQuotedText : nil)];
self.lastQuotedMessageView = quotedMessageView;
self.quotedMessageView = quotedMessageView;
[quotedMessageView createContents];
[self.bubbleView addSubview:quotedMessageView];
@ -319,7 +319,7 @@ NS_ASSUME_NONNULL_BEGIN
bodyMediaView.clipsToBounds = YES;
self.lastBodyMediaView = bodyMediaView;
self.bodyMediaView = bodyMediaView;
bodyMediaView.userInteractionEnabled = NO;
if (self.isMediaBeingSent) {
bodyMediaView.layer.opacity = 0.75f;
@ -566,7 +566,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == stillImageView);
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
if (stillImageView.image) {
return;
}
@ -589,7 +589,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == stillImageView);
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
stillImageView.image = nil;
};
@ -613,7 +613,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == animatedImageView);
OWSCAssert(strongSelf.bodyMediaView == animatedImageView);
if (animatedImageView.image) {
return;
}
@ -636,7 +636,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == animatedImageView);
OWSCAssert(strongSelf.bodyMediaView == animatedImageView);
animatedImageView.image = nil;
};
@ -694,7 +694,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == stillImageView);
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
if (stillImageView.image) {
return;
}
@ -712,7 +712,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.lastBodyMediaView == stillImageView);
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
stillImageView.image = nil;
};
@ -1038,35 +1038,35 @@ NS_ASSUME_NONNULL_BEGIN
self.loadCellContentBlock = nil;
self.unloadCellContentBlock = nil;
[self.lastBodyMediaView removeFromSuperview];
self.lastBodyMediaView = nil;
[self.bodyMediaView removeFromSuperview];
self.bodyMediaView = nil;
[self.lastQuotedMessageView removeFromSuperview];
self.lastQuotedMessageView = nil;
[self.quotedMessageView removeFromSuperview];
self.quotedMessageView = nil;
}
#pragma mark - Gestures
- (OWSMessageGestureLocation)gestureLocationForLocation:(CGPoint)locationInMessageBubble
{
if (self.lastQuotedMessageView) {
if (self.quotedMessageView) {
// Treat this as a "quoted reply" gesture if:
//
// * There is a "quoted reply" view.
// * The gesture occured within or above the "quoted reply" view.
CGPoint location = [self convertPoint:locationInMessageBubble toView:self.lastQuotedMessageView];
if (location.y <= self.lastQuotedMessageView.height) {
CGPoint location = [self convertPoint:locationInMessageBubble toView:self.quotedMessageView];
if (location.y <= self.quotedMessageView.height) {
return OWSMessageGestureLocation_QuotedReply;
}
}
if (self.lastBodyMediaView) {
if (self.bodyMediaView) {
// Treat this as a "body media" gesture if:
//
// * There is a "body media" view.
// * The gesture occured within or above the "body media" view.
CGPoint location = [self convertPoint:locationInMessageBubble toView:self.lastBodyMediaView];
if (location.y <= self.lastBodyMediaView.height) {
CGPoint location = [self convertPoint:locationInMessageBubble toView:self.bodyMediaView];
if (location.y <= self.bodyMediaView.height) {
return OWSMessageGestureLocation_Media;
}
}

View file

@ -512,20 +512,20 @@ NS_ASSUME_NONNULL_BEGIN
case OWSMessageCellType_OversizeTextMessage:
break;
case OWSMessageCellType_StillImage:
OWSAssert(self.messageBubbleView.lastBodyMediaView);
OWSAssert(self.messageBubbleView.bodyMediaView);
OWSAssert(attachmentStream);
[self.delegate didTapImageViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.messageBubbleView.lastBodyMediaView];
imageView:self.messageBubbleView.bodyMediaView];
break;
case OWSMessageCellType_AnimatedImage:
OWSAssert(self.messageBubbleView.lastBodyMediaView);
OWSAssert(self.messageBubbleView.bodyMediaView);
OWSAssert(attachmentStream);
[self.delegate didTapImageViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.messageBubbleView.lastBodyMediaView];
imageView:self.messageBubbleView.bodyMediaView];
break;
case OWSMessageCellType_Audio:
OWSAssert(attachmentStream);
@ -533,12 +533,12 @@ NS_ASSUME_NONNULL_BEGIN
[self.delegate didTapAudioViewItem:self.viewItem attachmentStream:attachmentStream];
return;
case OWSMessageCellType_Video:
OWSAssert(self.messageBubbleView.lastBodyMediaView);
OWSAssert(self.messageBubbleView.bodyMediaView);
OWSAssert(attachmentStream);
[self.delegate didTapVideoViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.messageBubbleView.lastBodyMediaView];
imageView:self.messageBubbleView.bodyMediaView];
return;
case OWSMessageCellType_GenericAttachment:
OWSAssert(attachmentStream);