Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Persist person update on remote

Neeraj Gupta7429791a19eb
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index e756f34678..a96f962604 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -224,7 +224,7 @@ class FaceMLDataDB {
final List<int> fileId = [recentFileID];
int? avatarFileId;
if (person.data.avatarFaceId != null) {
- avatarFileId = int.tryParse(person.data.avatarFaceId!.split('-')[0]);
+ avatarFileId = int.tryParse(person.data.avatarFaceId!.split('_')[0]);
if (avatarFileId != null) {
fileId.add(avatarFileId);
}
@@ -485,27 +485,6 @@ class FaceMLDataDB {
await db.execute(fcClusterIDIndex);
}
- Future<void> insert(PersonEntity p, int cluserID) async {
- debugPrint("inserting person");
- final db = await instance.database;
- await db.insert(
- personTable,
- mapPersonToRow(p),
- conflictAlgorithm: ConflictAlgorithm.replace,
- );
- await assignClusterToPerson(personID: p.remoteID, clusterID: cluserID);
- }
-
- Future<void> updatePerson(PersonEntity p) async {
- final db = await instance.database;
- await db.update(
- personTable,
- mapPersonToRow(p),
- where: '$idColumn = ?',
- whereArgs: [p.remoteID],
- );
- }
-
Future<void> assignClusterToPerson({
required String personID,
required int clusterID,
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 55a7930abb..59f418273d 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
@@ -74,4 +74,12 @@ class PersonService {
);
return PersonEntity(result.id, data);
}
+
+ Future<void> updatePerson(PersonEntity updatePerson) async {
+ await entityService.addOrUpdate(
+ EntityType.person,
+ json.encode(updatePerson.data.toJson()),
+ id: updatePerson.remoteID,
+ );
+ }
}
diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
index 46b2527410..eb3b44f29d 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -8,7 +8,6 @@ import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
import 'package:photos/core/configuration.dart';
import "package:photos/core/event_bus.dart";
import "package:photos/events/people_changed_event.dart";
-import "package:photos/face/db.dart";
import "package:photos/face/model/person.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/models/collection/collection.dart';
@@ -22,6 +21,7 @@ import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/hidden_service.dart';
import 'package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart';
+import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/actions/collection/collection_file_actions.dart';
@@ -657,7 +657,7 @@ class _FileSelectionActionsWidgetState
data: widget.person!.data
.copyWith(avatarFaceId: file.uploadedFileID.toString()),
);
- await FaceMLDataDB.instance.updatePerson(newPerson);
+ await PersonService.instance.updatePerson(newPerson);
widget.selectedFiles.clearAll();
if (mounted) {
setState(() => {});
diff --git a/mobile/lib/ui/viewer/people/people_app_bar.dart b/mobile/lib/ui/viewer/people/people_app_bar.dart
index c1bd097cae..e8caccae5d 100644
--- a/mobile/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/lib/ui/viewer/people/people_app_bar.dart
@@ -7,12 +7,12 @@ import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
import "package:photos/events/people_changed_event.dart";
import 'package:photos/events/subscription_purchased_event.dart';
-import "package:photos/face/db.dart";
import "package:photos/face/model/person.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/models/gallery_type.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
+import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import "package:photos/ui/viewer/people/person_cluserts.dart";
import "package:photos/ui/viewer/people/person_cluster_suggestion.dart";
@@ -111,7 +111,7 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
try {
final updatePerson = widget.person
.copyWith(data: widget.person.data.copyWith(name: text));
- await FaceMLDataDB.instance.updatePerson(updatePerson);
+ await PersonService.instance.updatePerson(updatePerson);
if (mounted) {
_appBarTitle = text;
setState(() {});