forked from shadowfacts/Tusker
parent
f2f6eb81f7
commit
8db5649cd5
|
@ -107,10 +107,6 @@ class AttachmentView: GIFImageView {
|
|||
}
|
||||
|
||||
func loadAttachment() {
|
||||
guard AttachmentsContainerView.supportedAttachmentTypes.contains(attachment.kind) else {
|
||||
fatalError("invalid attachment type")
|
||||
}
|
||||
|
||||
if let hash = attachment.blurHash {
|
||||
AttachmentView.queue.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
@ -142,8 +138,8 @@ class AttachmentView: GIFImageView {
|
|||
loadAudio()
|
||||
case .gifv:
|
||||
loadGifv()
|
||||
default:
|
||||
fatalError("invalid attachment type")
|
||||
case .unknown:
|
||||
createUnknownLabel()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,6 +297,25 @@ class AttachmentView: GIFImageView {
|
|||
])
|
||||
}
|
||||
|
||||
func createUnknownLabel() {
|
||||
backgroundColor = .appSecondaryBackground
|
||||
let label = UILabel()
|
||||
label.text = "Unknown Attachment Type"
|
||||
label.numberOfLines = 0
|
||||
label.textAlignment = .center
|
||||
label.textColor = .secondaryLabel
|
||||
label.font = .preferredFont(forTextStyle: .body)
|
||||
label.adjustsFontForContentSizeCategory = true
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(label)
|
||||
NSLayoutConstraint.activate([
|
||||
label.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
label.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
label.topAnchor.constraint(equalTo: topAnchor),
|
||||
label.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
])
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func displayImage() {
|
||||
isGrayscale = Preferences.shared.grayscaleImages
|
||||
|
|
|
@ -11,8 +11,6 @@ import Pachyderm
|
|||
|
||||
class AttachmentsContainerView: UIView {
|
||||
|
||||
static let supportedAttachmentTypes = [Attachment.Kind.image, .video, .audio, .gifv]
|
||||
|
||||
weak var delegate: AttachmentViewDelegate?
|
||||
|
||||
private var attachmentTokens: [AttachmentToken] = []
|
||||
|
@ -70,7 +68,6 @@ class AttachmentsContainerView: UIView {
|
|||
// MARK: - User Interaface
|
||||
|
||||
func updateUI(attachments: [Attachment]) {
|
||||
let attachments = attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) }
|
||||
let newTokens = attachments.map { AttachmentToken(attachment: $0) }
|
||||
|
||||
guard self.attachmentTokens != newTokens else {
|
||||
|
|
Loading…
Reference in New Issue