filter caption strings for display

This commit is contained in:
Michael Kirk 2018-11-09 09:18:11 -06:00
parent 3b53ee08ba
commit 74b25c14f1
2 changed files with 10 additions and 6 deletions

View file

@ -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: {})

View file

@ -172,7 +172,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
captionViewsContainer.addSubview(currentCaptionView)
currentCaptionView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
currentCaptionView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
currentCaptionView.text = currentItem.caption
currentCaptionView.text = currentItem.captionForDisplay
let pendingCaptionView = CaptionView()
self.pendingCaptionView = pendingCaptionView
@ -447,7 +447,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
CATransaction.begin()
CATransaction.disableActions()
if let pendingCaptionText = pendingViewController.galleryItem.caption, pendingCaptionText.count > 0 {
if let pendingCaptionText = pendingViewController.galleryItem.captionForDisplay, pendingCaptionText.count > 0 {
self.pendingCaptionView.text = pendingCaptionText
} else {
self.pendingCaptionView.text = nil