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

29 lines
847 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
2023-01-10 08:04:25 +01:00
import MastodonKit
2023-01-05 11:55:20 +01:00
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
}
}