Impressia/Vernissage/CoreData/AttachmentData+Attachment.s...

30 lines
854 B
Swift
Raw Normal View History

2023-01-05 11:55:20 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import Foundation
import MastodonSwift
extension AttachmentData {
func copyFrom(_ attachment: Attachment) {
self.id = attachment.id
self.url = attachment.url
self.blurhash = attachment.blurhash
self.previewUrl = attachment.previewUrl
self.remoteUrl = attachment.remoteUrl
self.text = attachment.description
self.type = attachment.type.rawValue
if let width = (attachment.meta as? ImageMetadata)?.original?.width {
self.metaImageWidth = Int32(width)
}
if let height = (attachment.meta as? ImageMetadata)?.original?.height {
self.metaImageHeight = Int32(height)
}
2023-01-05 11:55:20 +01:00
}
}