fix types
This commit is contained in:
@@ -6,33 +6,33 @@ enum RemoteAssetMetadataKey {
|
||||
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;
|
||||
class RemoteAssetMetadataItem {
|
||||
final RemoteAssetMetadataKey key;
|
||||
final Object value;
|
||||
|
||||
const RemoteAssetMetadata({this.cloudId});
|
||||
const RemoteAssetMetadataItem({required this.key, required this.value});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final mobileAppValue = {};
|
||||
if (cloudId != null) {
|
||||
mobileAppValue["iCloudId"] = cloudId;
|
||||
}
|
||||
|
||||
return {
|
||||
"metadata": [
|
||||
{"key": RemoteAssetMetadataKey.mobileApp.key, "value": mobileAppValue},
|
||||
],
|
||||
};
|
||||
Map<String, Object?> toMap() {
|
||||
return {'key': key.key, 'value': value};
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
|
||||
class RemoteAssetMobileAppMetadata {
|
||||
final String? cloudId;
|
||||
|
||||
const RemoteAssetMobileAppMetadata({this.cloudId});
|
||||
|
||||
Map<String, Object?> toMap() {
|
||||
final map = <String, Object?>{};
|
||||
if (cloudId != null) {
|
||||
map["iCloudId"] = cloudId;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@@ -24,7 +24,7 @@ Future<void> migrateCloudIds(ProviderContainer ref) async {
|
||||
for (final mapping in mappingsToUpdate) {
|
||||
final mobileMeta = AssetMetadataUpsertItemDto(
|
||||
key: AssetMetadataKey.mobileApp,
|
||||
value: {"iCloudId": mapping.cloudId},
|
||||
value: RemoteAssetMobileAppMetadata(cloudId: mapping.cloudId).toMap(),
|
||||
);
|
||||
await assetApi.updateAssetMetadata(mapping.assetId, AssetMetadataUpsertDto(items: [mobileMeta]));
|
||||
}
|
||||
@@ -52,7 +52,7 @@ Future<List<_CloudIdMapping>> _fetchCloudIdMappings(Drift drift) async {
|
||||
leftOuterJoin(
|
||||
drift.remoteAssetMetadataEntity,
|
||||
drift.remoteAssetMetadataEntity.assetId.equalsExp(drift.remoteAssetEntity.id) &
|
||||
drift.remoteAssetMetadataEntity.key.equalsValue(RemoteAssetMetadataKey.mobileApp),
|
||||
drift.remoteAssetMetadataEntity.key.equals(RemoteAssetMetadataKey.mobileApp.key),
|
||||
useColumns: false,
|
||||
),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user