mirror of
https://github.com/immich-app/immich.git
synced 2026-02-04 08:49:01 +03:00
* platform clients * uppercase http method * fix hot reload * custom user agent * init before app launch * set defaults * move to bootstrap * unrelated change * disable disk cache by default * optimized decoding * remove incremental * android impl * memory optimization * lock approach is slower on ios * conditional cronet * clarify parameter * enable disk cache * set user agent * flutter-side decode * optimized http * fixed locking * refactor * potential race conditions * embedded cronet * refactor, fix capacity handling * fast path for known content length * ios optimizations * re-enable cache * formatting * bump concurrency * clear cache button * fix eviction race condition * add extra cancellation check * tighten dispose * better error handling * fix disposal --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
135 lines
4.4 KiB
Swift
135 lines
4.4 KiB
Swift
// Autogenerated from Pigeon (v26.0.2), do not edit directly.
|
|
// See also: https://pub.dev/packages/pigeon
|
|
|
|
import Foundation
|
|
|
|
#if os(iOS)
|
|
import Flutter
|
|
#elseif os(macOS)
|
|
import FlutterMacOS
|
|
#else
|
|
#error("Unsupported platform.")
|
|
#endif
|
|
|
|
private func wrapResult(_ result: Any?) -> [Any?] {
|
|
return [result]
|
|
}
|
|
|
|
private func wrapError(_ error: Any) -> [Any?] {
|
|
if let pigeonError = error as? PigeonError {
|
|
return [
|
|
pigeonError.code,
|
|
pigeonError.message,
|
|
pigeonError.details,
|
|
]
|
|
}
|
|
if let flutterError = error as? FlutterError {
|
|
return [
|
|
flutterError.code,
|
|
flutterError.message,
|
|
flutterError.details,
|
|
]
|
|
}
|
|
return [
|
|
"\(error)",
|
|
"\(type(of: error))",
|
|
"Stacktrace: \(Thread.callStackSymbols)",
|
|
]
|
|
}
|
|
|
|
private func isNullish(_ value: Any?) -> Bool {
|
|
return value is NSNull || value == nil
|
|
}
|
|
|
|
private func nilOrValue<T>(_ value: Any?) -> T? {
|
|
if value is NSNull { return nil }
|
|
return value as! T?
|
|
}
|
|
|
|
|
|
private class RemoteImagesPigeonCodecReader: FlutterStandardReader {
|
|
}
|
|
|
|
private class RemoteImagesPigeonCodecWriter: FlutterStandardWriter {
|
|
}
|
|
|
|
private class RemoteImagesPigeonCodecReaderWriter: FlutterStandardReaderWriter {
|
|
override func reader(with data: Data) -> FlutterStandardReader {
|
|
return RemoteImagesPigeonCodecReader(data: data)
|
|
}
|
|
|
|
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
|
|
return RemoteImagesPigeonCodecWriter(data: data)
|
|
}
|
|
}
|
|
|
|
class RemoteImagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
|
|
static let shared = RemoteImagesPigeonCodec(readerWriter: RemoteImagesPigeonCodecReaderWriter())
|
|
}
|
|
|
|
|
|
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
|
|
protocol RemoteImageApi {
|
|
func requestImage(url: String, headers: [String: String], requestId: Int64, completion: @escaping (Result<[String: Int64]?, Error>) -> Void)
|
|
func cancelRequest(requestId: Int64) throws
|
|
func clearCache(completion: @escaping (Result<Int64, Error>) -> Void)
|
|
}
|
|
|
|
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
|
|
class RemoteImageApiSetup {
|
|
static var codec: FlutterStandardMessageCodec { RemoteImagesPigeonCodec.shared }
|
|
/// Sets up an instance of `RemoteImageApi` to handle messages through the `binaryMessenger`.
|
|
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: RemoteImageApi?, messageChannelSuffix: String = "") {
|
|
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
|
|
let requestImageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.RemoteImageApi.requestImage\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
requestImageChannel.setMessageHandler { message, reply in
|
|
let args = message as! [Any?]
|
|
let urlArg = args[0] as! String
|
|
let headersArg = args[1] as! [String: String]
|
|
let requestIdArg = args[2] as! Int64
|
|
api.requestImage(url: urlArg, headers: headersArg, requestId: requestIdArg) { result in
|
|
switch result {
|
|
case .success(let res):
|
|
reply(wrapResult(res))
|
|
case .failure(let error):
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
requestImageChannel.setMessageHandler(nil)
|
|
}
|
|
let cancelRequestChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.RemoteImageApi.cancelRequest\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
cancelRequestChannel.setMessageHandler { message, reply in
|
|
let args = message as! [Any?]
|
|
let requestIdArg = args[0] as! Int64
|
|
do {
|
|
try api.cancelRequest(requestId: requestIdArg)
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
cancelRequestChannel.setMessageHandler(nil)
|
|
}
|
|
let clearCacheChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.RemoteImageApi.clearCache\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
clearCacheChannel.setMessageHandler { _, reply in
|
|
api.clearCache { result in
|
|
switch result {
|
|
case .success(let res):
|
|
reply(wrapResult(res))
|
|
case .failure(let error):
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
clearCacheChannel.setMessageHandler(nil)
|
|
}
|
|
}
|
|
}
|