Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mob] Misc bug fixes #3522

Merged
merged 7 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mobile/lib/services/entity_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class EntityService {
}
}

Future<void> syncEntity(EntityType type) async {
try {
await _remoteToLocalSync(type);
} catch (e) {
_logger.severe("Failed to sync entities", e);
}
}

Future<void> _remoteToLocalSync(EntityType type) async {
final int lastSyncTime =
_prefs.getInt(_getEntityLastSyncTimePrefix(type)) ?? 0;
Expand All @@ -116,7 +124,6 @@ class EntityService {
limit: fetchLimit,
);
if (result.isEmpty) {
debugPrint("No $type entries to sync");
return;
}
final bool hasMoreItems = result.length == fetchLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/diff_sync_complete_event.dart";
import "package:photos/events/people_changed_event.dart";
import "package:photos/models/api/entity/type.dart";
import "package:photos/services/entity_service.dart";
import "package:photos/services/machine_learning/face_ml/face_detection/detection.dart";
import "package:photos/services/machine_learning/face_ml/face_detection/face_detection_service.dart";
import "package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart";
Expand Down Expand Up @@ -59,6 +61,7 @@ class FaceRecognitionService {
return;
}
_isSyncing = true;
await EntityService.instance.syncEntity(EntityType.cgroup);
if (_shouldSyncPeople) {
await PersonService.instance.reconcileClusters();
Bus.instance.fire(PeopleChangedEvent(type: PeopleEventType.syncDone));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class ClusterFeedbackService {
}

Future<void> ignoreCluster(String clusterID) async {
await PersonService.instance.addPerson('', clusterID);
await PersonService.instance.addPerson('', clusterID, isHidden: true);
Bus.instance.fire(PeopleChangedEvent());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "package:photos/db/ml/db.dart";
import "package:photos/events/people_changed_event.dart";
import "package:photos/extensions/stop_watch.dart";
import "package:photos/models/api/entity/type.dart";
import "package:photos/models/file/file.dart";
import 'package:photos/models/ml/face/face.dart';
import "package:photos/models/ml/face/person.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/entity_service.dart";
Expand Down Expand Up @@ -292,6 +294,24 @@ class PersonService {
await faceMLDataDB.bulkAssignClusterToPersonID(clusterToPersonID);
}

Future<void> updateAvatar(PersonEntity p, EnteFile file) async {
final Face? face = await MLDataDB.instance.getCoverFaceForPerson(
recentFileID: file.uploadedFileID!,
personID: p.remoteID,
);
if (face == null) {
throw Exception(
"No face found for person ${p.remoteID} in file ${file.uploadedFileID}",
);
}

final person = (await getPerson(p.remoteID))!;
final updatedPerson = person.copyWith(
data: person.data.copyWith(avatarFaceId: face.faceID),
);
await _updatePerson(updatedPerson);
}

Future<void> updateAttributes(
String id, {
String? name,
Expand Down
8 changes: 1 addition & 7 deletions mobile/lib/services/remote_sync_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ class RemoteSyncService {
await syncDeviceCollectionFilesForUpload();
}
await _pullDiff();
// sync trash but consume error during initial launch.
// this is to ensure that we don't pause upload due to any error during
// the trash sync. Impact: We may end up re-uploading a file which was
// recently trashed.
await TrashSyncService.instance
.syncTrash()
.onError((e, s) => _logger.severe('trash sync failed', e, s));
await TrashSyncService.instance.syncTrash();
if (!hasSyncedBefore) {
await _prefs.setBool(_isFirstRemoteSyncDone, true);
await syncDeviceCollectionFilesForUpload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,7 @@ class _FileSelectionActionsWidgetState

Future<void> _setPersonCover() async {
final EnteFile file = widget.selectedFiles.files.first;
await PersonService.instance.updateAttributes(
widget.person!.remoteID,
avatarFaceId: file.uploadedFileID.toString(),
);
await PersonService.instance.updateAvatar(widget.person!, file);
widget.selectedFiles.clearAll();
if (mounted) {
setState(() => {});
Expand Down
2 changes: 1 addition & 1 deletion mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: ente photos application
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 0.9.45+945
version: 0.9.46+946
publish_to: none

environment:
Expand Down