mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Prevent too much back and forth through the FFI layer when dealing with MediaSources
This commit is contained in:
@@ -24,30 +24,27 @@ struct MediaSourceProxy: Hashable {
|
|||||||
/// This is optional when loading images and thumbnails in memory.
|
/// This is optional when loading images and thumbnails in memory.
|
||||||
let mimeType: String?
|
let mimeType: String?
|
||||||
|
|
||||||
|
let url: URL!
|
||||||
|
|
||||||
init(source: MediaSource, mimeType: String?) {
|
init(source: MediaSource, mimeType: String?) {
|
||||||
underlyingSource = source
|
underlyingSource = source
|
||||||
|
url = URL(string: underlyingSource.url())
|
||||||
self.mimeType = mimeType
|
self.mimeType = mimeType
|
||||||
}
|
}
|
||||||
|
|
||||||
init(url: URL, mimeType: String?) {
|
init(url: URL, mimeType: String?) {
|
||||||
underlyingSource = mediaSourceFromUrl(url: url.absoluteString)
|
underlyingSource = mediaSourceFromUrl(url: url.absoluteString)
|
||||||
|
self.url = URL(string: underlyingSource.url())
|
||||||
self.mimeType = mimeType
|
self.mimeType = mimeType
|
||||||
}
|
}
|
||||||
|
|
||||||
var url: URL! {
|
// MARK: - Hashable
|
||||||
// Expecting these to always be valid URLs
|
|
||||||
URL(string: underlyingSource.url())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Hashable
|
public static func == (lhs: MediaSourceProxy, rhs: MediaSourceProxy) -> Bool {
|
||||||
|
lhs.url == rhs.url
|
||||||
extension MediaSource: Hashable {
|
|
||||||
public static func == (lhs: MediaSource, rhs: MediaSource) -> Bool {
|
|
||||||
lhs.url() == rhs.url()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hash(into hasher: inout Hasher) {
|
public func hash(into hasher: inout Hasher) {
|
||||||
hasher.combine(url())
|
hasher.combine(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user