mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
inline
This commit is contained in:
parent
4d4a5b6be4
commit
91a5989929
@ -25,8 +25,8 @@ class ThumbnailApiImpl: ThumbnailApi {
|
|||||||
guard let bufferPointer = UnsafeMutableRawPointer(bitPattern: Int(pointer))
|
guard let bufferPointer = UnsafeMutableRawPointer(bitPattern: Int(pointer))
|
||||||
else { completion(.failure(PigeonError(code: "", message: "Could not get buffer pointer for \(assetId)", details: nil))); return }
|
else { completion(.failure(PigeonError(code: "", message: "Could not get buffer pointer for \(assetId)", details: nil))); return }
|
||||||
Self.processingQueue.async {
|
Self.processingQueue.async {
|
||||||
do {
|
guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: Self.fetchOptions).firstObject
|
||||||
let asset = try self.getAsset(assetId: assetId)
|
else { completion(.failure(PigeonError(code: "", message: "Could not get asset data for \(assetId)", details: nil))); return }
|
||||||
Self.cacheManager.requestImage(
|
Self.cacheManager.requestImage(
|
||||||
for: asset,
|
for: asset,
|
||||||
targetSize: CGSize(width: Double(width), height: Double(height)),
|
targetSize: CGSize(width: Double(width), height: Double(height)),
|
||||||
@ -50,20 +50,6 @@ class ThumbnailApiImpl: ThumbnailApi {
|
|||||||
completion(.success(()))
|
completion(.success(()))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} catch {
|
|
||||||
completion(
|
|
||||||
.failure(PigeonError(code: "", message: "Could not get asset data for \(assetId)", details: nil)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private func getAsset(assetId: String) throws -> PHAsset {
|
|
||||||
guard
|
|
||||||
let asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: Self.fetchOptions)
|
|
||||||
.firstObject
|
|
||||||
else {
|
|
||||||
throw PigeonError(code: "", message: "Could not fetch asset", details: nil)
|
|
||||||
}
|
|
||||||
return asset
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user