Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix info types

Neeraj Gupta30456f120f7d
diff --git a/mobile/apps/locker/lib/models/info/info_item.dart b/mobile/apps/locker/lib/models/info/info_item.dart
index 3ca7836a45..d76d70415c 100644
--- a/mobile/apps/locker/lib/models/info/info_item.dart
+++ b/mobile/apps/locker/lib/models/info/info_item.dart
@@ -8,18 +8,22 @@ enum InfoType {
emergencyContact,
}
-// Extension to convert enum to string and vice versa
+// Extension to convert enum to string and vice versa.
+//
+// Locker file metadata currently uses the enum's camelCase name on the wire.
+// Keep parsing tolerant of the older hyphenated representation so any
+// previously serialized JSON can still be read safely.
extension InfoTypeExtension on InfoType {
String get value {
switch (this) {
case InfoType.note:
return 'note';
case InfoType.physicalRecord:
- return 'physical-record';
+ return 'physicalRecord';
case InfoType.accountCredential:
- return 'account-credential';
+ return 'accountCredential';
case InfoType.emergencyContact:
- return 'emergency-contact';
+ return 'emergencyContact';
}
}
@@ -27,10 +31,13 @@ extension InfoTypeExtension on InfoType {
switch (value) {
case 'note':
return InfoType.note;
+ case 'physicalRecord':
case 'physical-record':
return InfoType.physicalRecord;
+ case 'accountCredential':
case 'account-credential':
return InfoType.accountCredential;
+ case 'emergencyContact':
case 'emergency-contact':
return InfoType.emergencyContact;
default:
diff --git a/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart b/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
index 7a89419b81..7c4646f06e 100644
--- a/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
+++ b/mobile/apps/locker/lib/services/files/sync/models/file_magic.dart
@@ -75,9 +75,9 @@ class PubMagicMetadata {
// 1 -> panorama
int? mediaType;
- // JSON containing information data for info files
- // Contains type (note, physical-record, account-credential, emergency-contact)
- // and data (the actual information content)
+ // JSON containing information data for info files.
+ // Locker currently writes camelCase type values
+ // (note, physicalRecord, accountCredential, emergencyContact).
Map<String, dynamic>? info;
PubMagicMetadata({