Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent c7582b6bd7
commit 82fb766c27

@ -81,7 +81,7 @@ public class ConversationMediaView: UIView {
return return
} }
guard let progress = attachmentDownloads.downloadProgress(forAttachmentId: attachmentId) else { guard nil != attachmentDownloads.downloadProgress(forAttachmentId: attachmentId) else {
// Not being downloaded. // Not being downloaded.
configureForMissingOrInvalid() configureForMissingOrInvalid()
return return
@ -94,7 +94,7 @@ public class ConversationMediaView: UIView {
} }
private func addUploadProgressIfNecessary(_ subview: UIView, private func addUploadProgressIfNecessary(_ subview: UIView,
progressCallback: @escaping ProgressCallback) { progressCallback: ProgressCallback? = nil) {
guard isOutgoing else { guard isOutgoing else {
return return
} }
@ -105,7 +105,9 @@ public class ConversationMediaView: UIView {
return return
} }
let uploadView = AttachmentUploadView(attachment: attachmentStream) { (isAttachmentReady) in let uploadView = AttachmentUploadView(attachment: attachmentStream) { (isAttachmentReady) in
progressCallback(isAttachmentReady) if let progressCallback = progressCallback {
progressCallback(isAttachmentReady)
}
} }
subview.addSubview(uploadView) subview.addSubview(uploadView)
uploadView.autoPinEdgesToSuperviewEdges() uploadView.autoPinEdgesToSuperviewEdges()
@ -127,8 +129,8 @@ public class ConversationMediaView: UIView {
animatedImageView.backgroundColor = Theme.offBackgroundColor animatedImageView.backgroundColor = Theme.offBackgroundColor
addSubview(animatedImageView) addSubview(animatedImageView)
animatedImageView.autoPinEdgesToSuperviewEdges() animatedImageView.autoPinEdgesToSuperviewEdges()
addUploadProgressIfNecessary(animatedImageView) { (_) in addUploadProgressIfNecessary(animatedImageView)
}
loadBlock = { [weak self] in loadBlock = { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -148,8 +150,8 @@ public class ConversationMediaView: UIView {
let animatedImage = YYImage(contentsOfFile: filePath) let animatedImage = YYImage(contentsOfFile: filePath)
return animatedImage return animatedImage
}, },
cacheKey: cacheKey, cacheKey: cacheKey,
canLoadAsync: true) canLoadAsync: true)
guard let image = cachedValue as? YYImage else { guard let image = cachedValue as? YYImage else {
return return
} }
@ -176,8 +178,7 @@ public class ConversationMediaView: UIView {
stillImageView.backgroundColor = Theme.offBackgroundColor stillImageView.backgroundColor = Theme.offBackgroundColor
addSubview(stillImageView) addSubview(stillImageView)
stillImageView.autoPinEdgesToSuperviewEdges() stillImageView.autoPinEdgesToSuperviewEdges()
addUploadProgressIfNecessary(stillImageView) { (_) in addUploadProgressIfNecessary(stillImageView)
}
loadBlock = { [weak self] in loadBlock = { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -196,8 +197,8 @@ public class ConversationMediaView: UIView {
Logger.error("Could not load thumbnail") Logger.error("Could not load thumbnail")
}) })
}, },
cacheKey: cacheKey, cacheKey: cacheKey,
canLoadAsync: true) canLoadAsync: true)
guard let image = cachedValue as? UIImage else { guard let image = cachedValue as? UIImage else {
return return
} }

Loading…
Cancel
Save