|
|
|
@ -4,6 +4,12 @@
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension String {
|
|
|
|
|
var filterForDisplay: String? {
|
|
|
|
|
return (self as NSString).filterStringForDisplay()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GalleryDirection {
|
|
|
|
|
case before, after, around
|
|
|
|
|
}
|
|
|
|
@ -12,10 +18,12 @@ public class MediaGalleryItem: Equatable, Hashable {
|
|
|
|
|
let message: TSMessage
|
|
|
|
|
let attachmentStream: TSAttachmentStream
|
|
|
|
|
let galleryDate: GalleryDate
|
|
|
|
|
let captionForDisplay: String?
|
|
|
|
|
|
|
|
|
|
init(message: TSMessage, attachmentStream: TSAttachmentStream) {
|
|
|
|
|
self.message = message
|
|
|
|
|
self.attachmentStream = attachmentStream
|
|
|
|
|
self.captionForDisplay = attachmentStream.caption?.filterForDisplay
|
|
|
|
|
self.galleryDate = GalleryDate(message: message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -31,10 +39,6 @@ public class MediaGalleryItem: Equatable, Hashable {
|
|
|
|
|
return attachmentStream.isImage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var caption: String? {
|
|
|
|
|
return attachmentStream.caption
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public typealias AsyncThumbnailBlock = (UIImage) -> Void
|
|
|
|
|
func thumbnailImage(async:@escaping AsyncThumbnailBlock) -> UIImage? {
|
|
|
|
|
return attachmentStream.thumbnailImageSmall(success: async, failure: {})
|
|
|
|
|