mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Run SwiftFormat.
This commit is contained in:
@@ -358,7 +358,7 @@ struct MediaUploadingPreprocessor {
|
||||
|
||||
return .init(url: thumbnailURL, height: thumbnail.size.height, width: thumbnail.size.width, mimeType: "image/jpeg", blurhash: blurhash)
|
||||
}
|
||||
|
||||
|
||||
private func resizeImage(at url: URL, maxPixelSize: CGFloat, destination: URL, type: UTType) throws(MediaUploadingPreprocessorError) {
|
||||
guard let imageSource = CGImageSourceCreateWithURL(url as NSURL, nil) else {
|
||||
throw .failedResizingImage
|
||||
@@ -440,7 +440,7 @@ struct MediaUploadingPreprocessor {
|
||||
private func convertVideoToMP4(_ url: URL, targetFileSize: UInt) async throws(MediaUploadingPreprocessorError) -> VideoProcessingInfo {
|
||||
let asset = AVURLAsset(url: url)
|
||||
let presetName = appSettings.optimizeMediaUploads ? AVAssetExportPreset1280x720 : AVAssetExportPreset1920x1080
|
||||
|
||||
|
||||
guard let exportSession = AVAssetExportSession(asset: asset, presetName: presetName) else {
|
||||
throw .failedConvertingVideo
|
||||
}
|
||||
@@ -524,11 +524,11 @@ private extension AVAssetTrack {
|
||||
guard mediaType == .video else {
|
||||
return naturalSize
|
||||
}
|
||||
|
||||
|
||||
// The naturalSize does not take the preferredTransform into consideration resulting
|
||||
// in portrait videos reporting inverted values.
|
||||
let transform = try await load(.preferredTransform)
|
||||
|
||||
|
||||
switch (transform.a, transform.b, transform.c, transform.d) {
|
||||
case (0, 1, -1, 0), (0, -1, 1, 0):
|
||||
return CGSize(width: naturalSize.height, height: naturalSize.width)
|
||||
|
||||
@@ -29,7 +29,7 @@ actor MediaLoader: MediaLoaderProtocol {
|
||||
// don't have an accompanying ClientMock to own it.
|
||||
private weak var client: ClientProtocol?
|
||||
private var ongoingRequests = [MediaSourceProxy: MediaRequest]()
|
||||
|
||||
|
||||
init(client: ClientProtocol) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ enum MediaLoaderError: Error {
|
||||
// sourcery: AutoMockable
|
||||
protocol MediaLoaderProtocol: Sendable {
|
||||
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data
|
||||
|
||||
|
||||
func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data
|
||||
|
||||
func loadMediaFileForSource(_ source: MediaSourceProxy, filename: String?) async throws -> MediaFileHandleProxy
|
||||
|
||||
@@ -44,7 +44,7 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
let image = cacheResult.image {
|
||||
return .success(image)
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
let imageData: Data
|
||||
if let size {
|
||||
@@ -52,14 +52,14 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
} else {
|
||||
imageData = try await mediaLoader.loadMediaContentForSource(source)
|
||||
}
|
||||
|
||||
|
||||
guard let image = UIImage(data: imageData) else {
|
||||
MXLog.error("Invalid image data")
|
||||
return .failure(.invalidImageData)
|
||||
}
|
||||
|
||||
|
||||
try await imageCache.store(image, forKey: cacheKey)
|
||||
|
||||
|
||||
return .success(image)
|
||||
} catch {
|
||||
MXLog.error("Failed retrieving image with error: \(error)")
|
||||
|
||||
Reference in New Issue
Block a user