mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Ignore redundant body text view updates; cache body text view size.
This commit is contained in:
parent
ea765437ef
commit
21c630c095
|
@ -7,6 +7,14 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSMessageTextView ()
|
||||
|
||||
@property (nonatomic, nullable) NSValue *cachedSize;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSMessageTextView
|
||||
|
||||
// Our message text views are never used for editing;
|
||||
|
@ -61,6 +69,61 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return result;
|
||||
}
|
||||
|
||||
- (void)setText:(nullable NSString *)text
|
||||
{
|
||||
if ([NSObject isNullableObject:text equalTo:self.text]) {
|
||||
return;
|
||||
}
|
||||
[super setText:text];
|
||||
self.cachedSize = nil;
|
||||
}
|
||||
|
||||
- (void)setAttributedText:(nullable NSAttributedString *)attributedText
|
||||
{
|
||||
if ([NSObject isNullableObject:attributedText equalTo:self.attributedText]) {
|
||||
return;
|
||||
}
|
||||
[super setAttributedText:attributedText];
|
||||
self.cachedSize = nil;
|
||||
}
|
||||
|
||||
- (void)setTextColor:(nullable UIColor *)textColor
|
||||
{
|
||||
if ([NSObject isNullableObject:textColor equalTo:self.textColor]) {
|
||||
return;
|
||||
}
|
||||
[super setTextColor:textColor];
|
||||
self.cachedSize = nil;
|
||||
}
|
||||
|
||||
- (void)setFont:(nullable UIFont *)font
|
||||
{
|
||||
if ([NSObject isNullableObject:font equalTo:self.font]) {
|
||||
return;
|
||||
}
|
||||
[super setFont:font];
|
||||
self.cachedSize = nil;
|
||||
}
|
||||
|
||||
- (void)setLinkTextAttributes:(nullable NSDictionary<NSString *, id> *)linkTextAttributes
|
||||
{
|
||||
if ([NSObject isNullableObject:linkTextAttributes equalTo:self.linkTextAttributes]) {
|
||||
return;
|
||||
}
|
||||
[super setLinkTextAttributes:linkTextAttributes];
|
||||
self.cachedSize = nil;
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size
|
||||
{
|
||||
if (self.cachedSize) {
|
||||
return self.cachedSize.CGSizeValue;
|
||||
}
|
||||
CGSize result = [super sizeThatFits:size];
|
||||
self.cachedSize = [NSValue valueWithCGSize:result];
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
Loading…
Reference in a new issue