mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
701 B
Swift
28 lines
701 B
Swift
3 years ago
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
public struct LinkPreviewDraft: Equatable, Hashable {
|
||
|
public var urlString: String
|
||
|
public var title: String?
|
||
|
public var jpegImageData: Data?
|
||
|
|
||
|
public init(urlString: String, title: String?, jpegImageData: Data? = nil) {
|
||
|
self.urlString = urlString
|
||
|
self.title = title
|
||
|
self.jpegImageData = jpegImageData
|
||
|
}
|
||
|
|
||
|
public func isValid() -> Bool {
|
||
|
var hasTitle = false
|
||
|
|
||
|
if let titleValue = title {
|
||
|
hasTitle = titleValue.count > 0
|
||
|
}
|
||
|
|
||
|
let hasImage = jpegImageData != nil
|
||
|
|
||
|
return (hasTitle || hasImage)
|
||
|
}
|
||
|
}
|