aboutsummaryrefslogtreecommitdiffhomepage
path: root/example/ios
diff options
context:
space:
mode:
Diffstat (limited to 'example/ios')
-rwxr-xr-xexample/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm21
1 files changed, 14 insertions, 7 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm b/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
index 97946a96..5e89f33b 100755
--- a/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
+++ b/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
@@ -139,16 +139,23 @@
NSString * partUniqueID = [part uniqueID];
NSData * data = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
+
+ void (^replaceImages)(NSError *error) = ^(NSError *error) {
+ NSData * downloadedData = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
+ NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[self _isCID:url]];
+ NSString *filename = [NSString stringWithFormat:@"%lu", (unsigned long)urlString.hash];
+ NSURL *cacheURL = [self _cacheJPEGImageData:previewData withFilename:filename];
+
+ NSString *replaceScript = [NSString stringWithFormat:@"replaceImageSrc(\"%@\", \"%@\")", urlString, cacheURL.absoluteString];
+ [_webView stringByEvaluatingJavaScriptFromString:replaceScript];
+ };
+
if (data == NULL) {
[[self delegate] MCOMessageView:self fetchDataForPartWithUniqueID:partUniqueID downloadedFinished:^(NSError * error) {
- NSData * downloadedData = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
- NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[self _isCID:url]];
- NSString *filename = [NSString stringWithFormat:@"%lu", (unsigned long)urlString.hash];
- NSURL *cacheURL = [self _cacheJPEGImageData:previewData withFilename:filename];
-
- NSString *replaceScript = [NSString stringWithFormat:@"replaceImageSrc(\"%@\", \"%@\")", urlString, cacheURL.absoluteString];
- [_webView stringByEvaluatingJavaScriptFromString:replaceScript];
+ replaceImages(error);
}];
+ } else {
+ replaceImages(nil);
}
}
}