Improve asserts and logging in attachment adapters.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent b1f7cf0d62
commit 964e6f1adf

@ -266,6 +266,11 @@ NS_ASSUME_NONNULL_BEGIN
NSString *utiType = [MIMETypeUtil utiTypeForMIMEType:self.attachment.contentType]; NSString *utiType = [MIMETypeUtil utiTypeForMIMEType:self.attachment.contentType];
OWSAssert(utiType.length > 0); OWSAssert(utiType.length > 0);
NSData *data = [NSData dataWithContentsOfURL:self.attachment.mediaURL]; NSData *data = [NSData dataWithContentsOfURL:self.attachment.mediaURL];
if (!data) {
OWSAssert(data);
DDLogError(@"%@ Could not load data: %@", [self tag], [self.attachment mediaURL]);
return;
}
[UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType]; [UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType];
} else { } else {
// Shouldn't get here, as only supported actions should be exposed via canPerformEditingAction // Shouldn't get here, as only supported actions should be exposed via canPerformEditingAction
@ -290,6 +295,18 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -57,8 +57,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) uint64_t expiresAtSeconds; @property (nonatomic) uint64_t expiresAtSeconds;
@property (nonatomic) uint32_t expiresInSeconds; @property (nonatomic) uint32_t expiresInSeconds;
@property (nonatomic, copy) NSDate *messageDate; @property (nonatomic) NSDate *messageDate;
@property (nonatomic, retain) NSString *messageBody; @property (nonatomic) NSString *messageBody;
@property (nonatomic) NSString *interactionUniqueId; @property (nonatomic) NSString *interactionUniqueId;

@ -400,6 +400,11 @@ NS_ASSUME_NONNULL_BEGIN
utiType = (NSString *)kUTTypeVideo; utiType = (NSString *)kUTTypeVideo;
} }
NSData *data = [NSData dataWithContentsOfURL:self.fileURL]; NSData *data = [NSData dataWithContentsOfURL:self.fileURL];
if (!data) {
OWSAssert(data);
DDLogError(@"%@ Could not load data: %@", [self tag], [self.attachment mediaURL]);
return;
}
[UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType]; [UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType];
return; return;
} else if (action == NSSelectorFromString(@"save:")) { } else if (action == NSSelectorFromString(@"save:")) {
@ -418,7 +423,11 @@ NS_ASSUME_NONNULL_BEGIN
} }
NSData *data = [NSData dataWithContentsOfURL:self.fileURL]; NSData *data = [NSData dataWithContentsOfURL:self.fileURL];
OWSAssert(data); if (!data) {
OWSAssert(data);
DDLogError(@"%@ Could not load data: %@", [self tag], [self.attachment mediaURL]);
return;
}
[UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType]; [UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType];
} }
} else { } else {
@ -446,6 +455,18 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -758,11 +758,11 @@ typedef enum : NSUInteger {
[[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ] view:TSMessageDatabaseViewExtensionName]; [[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ] view:TSMessageDatabaseViewExtensionName];
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[self.messageMappings updateWithTransaction:transaction]; [self.messageMappings updateWithTransaction:transaction];
self.page = 0;
[self updateRangeOptionsForPage:self.page];
[self.collectionView reloadData];
}]; }];
self.page = 0;
[self updateRangeOptionsForPage:self.page];
[self updateLoadEarlierVisible]; [self updateLoadEarlierVisible];
[self.collectionView reloadData];
} }
- (BOOL)userLeftGroup - (BOOL)userLeftGroup

Loading…
Cancel
Save