Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 7067085cdd
commit 316b55bf9d

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

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

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

Loading…
Cancel
Save