Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent b6649319da
commit 1c325cd210

@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
_image = [galleryItemBox.attachmentStream
thumbnailImageLargeWithSuccess:^(UIImage *image) {
weakSelf.image = image;
[weakSelf createContents];
[weakSelf updateContents];
[weakSelf updateMinZoomScale];
}
failure:^{
@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
self.view.backgroundColor = [UIColor clearColor];
[self createContents];
[self updateContents];
}
- (void)viewWillAppear:(BOOL)animated
@ -164,10 +164,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Initializers
- (void)createContents
- (void)updateContents
{
[self.mediaView removeFromSuperview];
[self.scrollView removeFromSuperview];
[self.playVideoButton removeFromSuperview];
[self.videoProgressBar removeFromSuperview];
UIScrollView *scrollView = [UIScrollView new];
[self.view addSubview:scrollView];

@ -15,21 +15,10 @@ public class MediaGalleryItem: Equatable, Hashable {
let attachmentStream: TSAttachmentStream
let galleryDate: GalleryDate
var presentationImage: UIImage?
init(message: TSMessage, attachmentStream: TSAttachmentStream) {
self.message = message
self.attachmentStream = attachmentStream
self.galleryDate = GalleryDate(message: message)
self.presentationImage = attachmentStream.thumbnailImageLarge(success: { [weak self] (image) in
guard let strongSelf = self else {
return
}
strongSelf.presentationImage = image
}, failure: {
Logger.warn("Could not load presentation image.")
})
}
var isVideo: Bool {
@ -306,7 +295,16 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
// loadView hasn't necessarily been called yet.
self.loadViewIfNeeded()
self.presentationView.image = initialDetailItem.presentationImage
self.presentationView.image = initialDetailItem.attachmentStream.thumbnailImageLarge(success: { [weak self] (image) in
guard let strongSelf = self else {
return
}
strongSelf.presentationView.image = image
}, failure: {
Logger.warn("Could not load presentation image.")
})
self.applyInitialMediaViewConstraints()
// Restore presentationView.alpha in case a previous dismiss left us in a bad state.
@ -483,7 +481,14 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
// it sits on the screen in the conversation view.
let changedItems = currentItem != self.initialDetailItem
if changedItems {
self.presentationView.image = currentItem.presentationImage
self.presentationView.image = currentItem.attachmentStream.thumbnailImageLarge(success: { [weak self] (image) in
guard let strongSelf = self else {
return
}
strongSelf.presentationView.image = image
}, failure: {
Logger.warn("Could not load presentation image.")
})
self.applyOffscreenMediaViewConstraints()
} else {
self.applyInitialMediaViewConstraints()

Loading…
Cancel
Save