Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 301c8c51a1
commit 2d76f2beb9

@ -111,7 +111,8 @@ typedef enum : NSUInteger {
@protocol OWSMessagesCollectionViewFlowLayoutDelegate <NSObject>
- (BOOL)isSpecialItemAtIndexPath:(NSIndexPath *)indexPath;
// Returns YES for incoming and outgoing text and attachment messages.
- (BOOL)isUserMessageAtIndexPath:(NSIndexPath *)indexPath;
@end
@ -130,7 +131,7 @@ typedef enum : NSUInteger {
- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// The unread indicator should be sized according to its desired size.
if ([self.delegate isSpecialItemAtIndexPath:indexPath]) {
if (![self.delegate isUserMessageAtIndexPath:indexPath]) {
CGSize messageBubbleSize = [self messageBubbleSizeForItemAtIndexPath:indexPath];
CGFloat finalHeight = messageBubbleSize.height;
return CGSizeMake(CGRectGetWidth(self.collectionView.frame), ceilf((float)finalHeight));
@ -1563,8 +1564,7 @@ typedef enum : NSUInteger {
OWSUnreadIndicatorCell *cell =
[self.collectionView dequeueReusableCellWithReuseIdentifier:[OWSUnreadIndicatorCell cellReuseIdentifier]
forIndexPath:indexPath];
cell.interaction = unreadIndicator;
[cell configure];
[cell configureWithInteraction:unreadIndicator];
return cell;
}
@ -1577,8 +1577,7 @@ typedef enum : NSUInteger {
OWSSystemMessageCell *cell =
[self.collectionView dequeueReusableCellWithReuseIdentifier:[OWSSystemMessageCell cellReuseIdentifier]
forIndexPath:indexPath];
cell.interaction = interaction;
[cell configure];
[cell configureWithInteraction:interaction];
return cell;
}
@ -3825,13 +3824,12 @@ typedef enum : NSUInteger {
#pragma mark - OWSMessagesCollectionViewFlowLayoutDelegate
- (BOOL)isSpecialItemAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)isUserMessageAtIndexPath:(NSIndexPath *)indexPath;
{
// TODO:
// TODO: Eventually it'd be nice to this in a more performant way.
TSInteraction *interaction = [self interactionAtIndexPath:indexPath];
return ([interaction isKindOfClass:[TSUnreadIndicatorInteraction class]] ||
[interaction isKindOfClass:[TSInfoMessage class]] || [interaction isKindOfClass:[TSErrorMessage class]] ||
[interaction isKindOfClass:[TSCall class]]);
return (
[interaction isKindOfClass:[TSIncomingMessage class]] || [interaction isKindOfClass:[TSOutgoingMessage class]]);
}
#pragma mark - Class methods

@ -42,15 +42,15 @@ NS_ASSUME_NONNULL_BEGIN
items:@[
[OWSTableItem itemWithTitle:@"Send 10 messages (1/sec.)"
actionBlock:^{
[DebugUIMessages sendTextMessage:10 thread:thread];
[DebugUIMessages sendTextMessages:10 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Send 100 messages (1/sec.)"
actionBlock:^{
[DebugUIMessages sendTextMessage:100 thread:thread];
[DebugUIMessages sendTextMessages:100 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Send 1,000 messages (1/sec.)"
actionBlock:^{
[DebugUIMessages sendTextMessage:1000 thread:thread];
[DebugUIMessages sendTextMessages:1000 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Send text/x-signal-plain"
actionBlock:^{
@ -146,22 +146,23 @@ NS_ASSUME_NONNULL_BEGIN
{
NSArray<NSString *> *randomTexts = @[
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
@"Suspendisse rutrum, nulla vitae pretium hendrerit, tellus "
@"turpis pharetra libero, vitae sodales tortor ante vel sem.",
(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
@"Suspendisse rutrum, nulla vitae pretium hendrerit, tellus "
@"turpis pharetra libero, vitae sodales tortor ante vel sem."),
@"In a time of universal deceit - telling the truth is a revolutionary act.",
@"If you want a vision of the future, imagine a boot stamping on a human face - forever.",
@"Who controls the past controls the future. Who controls the present controls the past.",
@"All animals are equal, but some animals are more equal than others.",
@"War is peace. Freedom is slavery. Ignorance is strength.",
@"All the war-propaganda, all the screaming and lies and hatred, comes invariably from people who are not "
@"fighting.",
@"Political language. . . is designed to make lies sound truthful and murder respectable, and to give an "
@"appearance of solidity to pure wind.",
@"The nationalist not only does not disapprove of atrocities committed by his own side, but he has a "
@"remarkable capacity for not even hearing about them.",
@"Every generation imagines itself to be more intelligent than the one that went before it, and wiser than the "
@"one that comes after it.",
(@"All the war-propaganda, all the screaming and lies and hatred, comes invariably from people who are not "
@"fighting."),
(@"Political language. . . is designed to make lies sound truthful and murder respectable, and to give an "
@"appearance of solidity to pure wind."),
(@"The nationalist not only does not disapprove of atrocities committed by his own side, but he has a "
@"remarkable capacity for not even hearing about them."),
(@"Every generation imagines itself to be more intelligent than the one that went before it, and wiser than "
@"the "
@"one that comes after it."),
@"War against a foreign country only happens when the moneyed classes think they are going to profit from it.",
];
NSString *randomText = randomTexts[(NSUInteger)arc4random_uniform((uint32_t)randomTexts.count)];
@ -170,14 +171,14 @@ NS_ASSUME_NONNULL_BEGIN
[ThreadUtil sendMessageWithText:text inThread:thread messageSender:messageSender];
}
+ (void)sendTextMessage:(int)counter thread:(TSThread *)thread
+ (void)sendTextMessages:(int)counter thread:(TSThread *)thread
{
if (counter < 1) {
return;
}
[self sendTextMessageInThread:thread counter:counter];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self sendTextMessage:counter - 1 thread:thread];
[self sendTextMessages:counter - 1 thread:thread];
});
}

@ -9,9 +9,9 @@
@interface OWSSystemMessageCell : JSQMessagesCollectionViewCell
@property (nonatomic) TSInteraction *interaction;
@property (nonatomic, nullable, readonly) TSInteraction *interaction;
- (void)configure;
- (void)configureWithInteraction:(TSInteraction *)interaction;
+ (CGSize)cellSizeForInteraction:(TSInteraction *)interaction collectionViewWidth:(CGFloat)collectionViewWidth;

@ -15,6 +15,8 @@
@interface OWSSystemMessageCell ()
@property (nonatomic, nullable) TSInteraction *interaction;
@property (nonatomic) UIImageView *imageView;
@property (nonatomic) UILabel *titleLabel;
@ -29,8 +31,12 @@
return NSStringFromClass([self class]);
}
- (void)configure
- (void)configureWithInteraction:(TSInteraction *)interaction;
{
OWSAssert(interaction);
_interaction = interaction;
self.backgroundColor = [UIColor whiteColor];
if (!self.titleLabel) {
@ -72,12 +78,12 @@
if ([interaction isKindOfClass:[TSErrorMessage class]]) {
switch (((TSErrorMessage *)self.interaction).errorType) {
case TSErrorMessageInvalidKeyException:
case TSErrorMessageNonBlockingIdentityChange:
case TSErrorMessageWrongTrustedIdentityKey:
case TSErrorMessageMissingKeyId:
result = [UIImage imageNamed:@"system_message_security"];
break;
case TSErrorMessageInvalidKeyException:
case TSErrorMessageMissingKeyId:
case TSErrorMessageNoSession:
case TSErrorMessageInvalidMessage:
case TSErrorMessageDuplicateMessage:
@ -89,8 +95,6 @@
} else if ([interaction isKindOfClass:[TSInfoMessage class]]) {
switch (((TSInfoMessage *)self.interaction).messageType) {
case TSInfoMessageUserNotRegistered:
result = [UIImage imageNamed:@"system_message_info"];
break;
case TSInfoMessageTypeSessionDidEnd:
case TSInfoMessageTypeUnsupportedMessage:
case TSInfoMessageAddToContactsOffer:
@ -202,4 +206,11 @@
return result;
}
- (void)prepareForReuse
{
[super prepareForReuse];
self.interaction = nil;
}
@end

@ -9,9 +9,10 @@
@interface OWSUnreadIndicatorCell : JSQMessagesCollectionViewCell
@property (nonatomic) TSUnreadIndicatorInteraction *interaction;
@property (nonatomic, nullable, readonly) TSUnreadIndicatorInteraction *interaction;
- (void)configure;
- (void)configureWithInteraction:(TSUnreadIndicatorInteraction *)interaction;
;
+ (CGSize)cellSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
collectionViewWidth:(CGFloat)collectionViewWidth;

@ -12,6 +12,8 @@
@interface OWSUnreadIndicatorCell ()
@property (nonatomic, nullable) TSUnreadIndicatorInteraction *interaction;
@property (nonatomic) UIView *bannerView;
@property (nonatomic) UIView *bannerTopHighlightView;
@property (nonatomic) UIView *bannerBottomHighlightView1;
@ -30,8 +32,12 @@
return NSStringFromClass([self class]);
}
- (void)configure
- (void)configureWithInteraction:(TSUnreadIndicatorInteraction *)interaction;
{
OWSAssert(interaction);
_interaction = interaction;
self.backgroundColor = [UIColor whiteColor];
if (!self.titleLabel) {
@ -205,4 +211,11 @@
return result;
}
- (void)prepareForReuse
{
[super prepareForReuse];
self.interaction = nil;
}
@end

Loading…
Cancel
Save