feat: add cloud id during native sync

# Conflicts:
#	mobile/lib/platform/native_sync_api.g.dart
This commit is contained in:
shenlong-tanwen
2025-07-30 02:01:55 +05:30
parent ada4265cf9
commit ecbaca3cee
5 changed files with 56 additions and 0 deletions
+16
View File
@@ -324,6 +324,7 @@ protocol NativeSyncApi {
func getAssetsCountSince(albumId: String, timestamp: Int64) throws -> Int64
func getAssetsForAlbum(albumId: String, updatedTimeCond: Int64?) throws -> [PlatformAsset]
func hashPaths(paths: [String]) throws -> [FlutterStandardTypedData?]
func getCloudIdForAssetIds(assetIds: [String]) throws -> [String: String?]
}
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
@@ -476,5 +477,20 @@ class NativeSyncApiSetup {
} else {
hashPathsChannel.setMessageHandler(nil)
}
let getCloudIdForAssetIdsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.NativeSyncApi.getCloudIdForAssetIds\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getCloudIdForAssetIdsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let assetIdsArg = args[0] as! [String]
do {
let result = try api.getCloudIdForAssetIds(assetIds: assetIdsArg)
reply(wrapResult(result))
} catch {
reply(wrapError(error))
}
}
} else {
getCloudIdForAssetIdsChannel.setMessageHandler(nil)
}
}
}
+16
View File
@@ -286,4 +286,20 @@ class NativeSyncApiImpl: NativeSyncApi {
return FlutterStandardTypedData(bytes: Data(digest))
}
}
func getCloudIdForAssetIds(assetIds: [String]) throws -> [String : String?] {
guard #available(iOS 16, *) else {
return Dictionary(
uniqueKeysWithValues: assetIds.map { ($0, nil as String?) }
)
}
var mappings: [String: String?] = [:]
let result = PHPhotoLibrary.shared().cloudIdentifierMappings(forLocalIdentifiers: assetIds)
for (key, value) in result {
let id = try? value.get().stringValue
mappings[key] = id
}
return mappings;
}
}