mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
filter caption strings for display
This commit is contained in:
parent
3b53ee08ba
commit
74b25c14f1
|
@ -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: {})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue