diff --git a/Signal/src/ViewControllers/MediaGalleryViewController.swift b/Signal/src/ViewControllers/MediaGalleryViewController.swift index bcf604e07..1903abbec 100644 --- a/Signal/src/ViewControllers/MediaGalleryViewController.swift +++ b/Signal/src/ViewControllers/MediaGalleryViewController.swift @@ -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: {}) diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index e53160a68..cbac03e92 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -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