sync remote asset metadata
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'dart:convert';
|
||||
|
||||
enum RemoteAssetMetadataKey {
|
||||
mobileApp("mobile-app");
|
||||
|
||||
final String key;
|
||||
|
||||
const RemoteAssetMetadataKey(this.key);
|
||||
|
||||
factory RemoteAssetMetadataKey.fromKey(String key) {
|
||||
switch (key) {
|
||||
case "mobile-app":
|
||||
return RemoteAssetMetadataKey.mobileApp;
|
||||
default:
|
||||
throw ArgumentError("Unknown AssetMetadataKey key: $key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteAssetMetadata {
|
||||
final String? cloudId;
|
||||
|
||||
const RemoteAssetMetadata({this.cloudId});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final mobileAppValue = {};
|
||||
if (cloudId != null) {
|
||||
mobileAppValue["iCloudId"] = cloudId;
|
||||
}
|
||||
|
||||
return {
|
||||
"metadata": [
|
||||
{"key": RemoteAssetMetadataKey.mobileApp.key, "value": mobileAppValue},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AssetMetadata {
|
||||
final String? cloudId;
|
||||
|
||||
const AssetMetadata({this.cloudId});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"metadata": [
|
||||
{
|
||||
"key": "mobile-app",
|
||||
"value": cloudId != null ? {"iCloudId": cloudId} : {},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
@@ -117,6 +117,10 @@ class SyncStreamService {
|
||||
return _syncStreamRepository.deleteAssetsV1(data.cast());
|
||||
case SyncEntityType.assetExifV1:
|
||||
return _syncStreamRepository.updateAssetsExifV1(data.cast());
|
||||
case SyncEntityType.assetMetadataV1:
|
||||
return _syncStreamRepository.updateAssetsMetadataV1(data.cast());
|
||||
case SyncEntityType.assetMetadataDeleteV1:
|
||||
return _syncStreamRepository.deleteAssetsMetadataV1(data.cast());
|
||||
case SyncEntityType.partnerAssetV1:
|
||||
return _syncStreamRepository.updateAssetsV1(data.cast(), debugLabel: 'partner');
|
||||
case SyncEntityType.partnerAssetBackfillV1:
|
||||
|
||||
Reference in New Issue
Block a user