Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor

Neeraj Guptadf46eeab10d5
diff --git a/mobile/lib/services/entity_service.dart b/mobile/lib/services/entity_service.dart
index 6ffe87358b..3f00d264fd 100644
--- a/mobile/lib/services/entity_service.dart
+++ b/mobile/lib/services/entity_service.dart
@@ -56,14 +56,13 @@ class EntityService {
Future<LocalEntityData> addOrUpdate(
EntityType type,
- String plainText, {
+ Map<String, dynamic> jsonMap, {
String? id,
}) async {
+ final String plainText = jsonEncode(jsonMap);
final key = await getOrCreateEntityKey(type);
- final encryptedKeyData = await CryptoUtil.encryptChaCha(
- utf8.encode(plainText),
- key,
- );
+ final encryptedKeyData =
+ await CryptoUtil.encryptChaCha(utf8.encode(plainText), key);
final String encryptedData =
CryptoUtil.bin2base64(encryptedKeyData.encryptedData!);
final String header = CryptoUtil.bin2base64(encryptedKeyData.header!);
diff --git a/mobile/lib/services/location_service.dart b/mobile/lib/services/location_service.dart
index f31a2803f6..f929dca525 100644
--- a/mobile/lib/services/location_service.dart
+++ b/mobile/lib/services/location_service.dart
@@ -90,7 +90,7 @@ class LocationService {
centerPoint: centerPoint,
);
await EntityService.instance
- .addOrUpdate(EntityType.location, json.encode(locationTag.toJson()));
+ .addOrUpdate(EntityType.location, locationTag.toJson());
Bus.instance.fire(LocationTagUpdatedEvent(LocTagEventType.add));
} catch (e, s) {
_logger.severe("Failed to add location tag", e, s);
@@ -179,7 +179,7 @@ class LocationService {
await EntityService.instance.addOrUpdate(
EntityType.location,
- json.encode(updatedLoationTag.toJson()),
+ updatedLoationTag.toJson(),
id: locationTagEntity.id,
);
Bus.instance.fire(
diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
index 187e51faf6..9a94b28160 100644
--- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
@@ -95,11 +95,7 @@ class PersonService {
)
.toList();
entityService
- .addOrUpdate(
- EntityType.person,
- json.encode(personData.toJson()),
- id: personID,
- )
+ .addOrUpdate(EntityType.person, personData.toJson(), id: personID)
.ignore();
personData.logStats();
}
@@ -168,7 +164,7 @@ class PersonService {
);
final result = await entityService.addOrUpdate(
EntityType.person,
- json.encode(data.toJson()),
+ data.toJson(),
);
await faceMLDataDB.assignClusterToPerson(
personID: result.id,
@@ -186,7 +182,7 @@ class PersonService {
personData.assigned!.removeWhere((element) => element.id != clusterID);
await entityService.addOrUpdate(
EntityType.person,
- json.encode(personData.toJson()),
+ personData.toJson(),
id: personID,
);
await faceMLDataDB.removeClusterToPerson(
@@ -221,7 +217,7 @@ class PersonService {
await entityService.addOrUpdate(
EntityType.person,
- json.encode(personData.toJson()),
+ personData.toJson(),
id: person.remoteID,
);
personData.logStats();
@@ -237,7 +233,7 @@ class PersonService {
PersonEntity(personID, PersonData(name: entity.data.name));
await entityService.addOrUpdate(
EntityType.person,
- json.encode(justName.data.toJson()),
+ justName.data.toJson(),
id: personID,
);
await faceMLDataDB.removePerson(personID);
@@ -312,7 +308,7 @@ class PersonService {
Future<void> _updatePerson(PersonEntity updatePerson) async {
await entityService.addOrUpdate(
EntityType.person,
- json.encode(updatePerson.data.toJson()),
+ updatePerson.data.toJson(),
id: updatePerson.remoteID,
);
updatePerson.data.logStats();