|
|
@ -16,7 +16,7 @@ public class MediaView: UIView {
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: -
|
|
|
|
// MARK: -
|
|
|
|
|
|
|
|
|
|
|
|
private let mediaCache: NSCache<NSString, AnyObject>
|
|
|
|
private let mediaCache: NSCache<NSString, AnyObject>?
|
|
|
|
public let attachment: Attachment
|
|
|
|
public let attachment: Attachment
|
|
|
|
private let isOutgoing: Bool
|
|
|
|
private let isOutgoing: Bool
|
|
|
|
private var loadBlock: (() -> Void)?
|
|
|
|
private var loadBlock: (() -> Void)?
|
|
|
@ -45,7 +45,7 @@ public class MediaView: UIView {
|
|
|
|
// MARK: - Initializers
|
|
|
|
// MARK: - Initializers
|
|
|
|
|
|
|
|
|
|
|
|
public required init(
|
|
|
|
public required init(
|
|
|
|
mediaCache: NSCache<NSString, AnyObject>,
|
|
|
|
mediaCache: NSCache<NSString, AnyObject>? = nil,
|
|
|
|
attachment: Attachment,
|
|
|
|
attachment: Attachment,
|
|
|
|
isOutgoing: Bool
|
|
|
|
isOutgoing: Bool
|
|
|
|
) {
|
|
|
|
) {
|
|
|
@ -393,7 +393,7 @@ public class MediaView: UIView {
|
|
|
|
|
|
|
|
|
|
|
|
applyMediaBlock(media)
|
|
|
|
applyMediaBlock(media)
|
|
|
|
|
|
|
|
|
|
|
|
self?.mediaCache.setObject(media, forKey: cacheKey as NSString)
|
|
|
|
self?.mediaCache?.setObject(media, forKey: cacheKey as NSString)
|
|
|
|
self?.loadState.mutate { $0 = .loaded }
|
|
|
|
self?.loadState.mutate { $0 = .loaded }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -402,7 +402,7 @@ public class MediaView: UIView {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let media: AnyObject = self.mediaCache.object(forKey: cacheKey as NSString) {
|
|
|
|
if let media: AnyObject = self.mediaCache?.object(forKey: cacheKey as NSString) {
|
|
|
|
Logger.verbose("media cache hit")
|
|
|
|
Logger.verbose("media cache hit")
|
|
|
|
|
|
|
|
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|