Skip to content

armgit / ente

Public Imported from GitHub
0

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

route to person memory

laurenspriem22e32baf34dc
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dart
index b74a8591a6..74ddf1654e 100644
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@ -20,9 +20,11 @@ import "package:photos/models/memories/smart_memory.dart";
import "package:photos/models/memories/smart_memory_constants.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/language_service.dart";
+import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import "package:photos/services/notification_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/ui/home/memories/full_screen_memory.dart";
+import "package:photos/ui/viewer/people/people_page.dart";
import "package:photos/utils/navigation_util.dart";
import "package:shared_preferences/shared_preferences.dart";
import "package:synchronized/synchronized.dart";
@@ -526,6 +528,57 @@ class MemoriesCacheService {
);
}
+ Future<void> goToPersonMemory(BuildContext context, String personID) async {
+ final allMemories = await getMemories();
+ if (allMemories.isEmpty) return;
+ final personMemories = <PeopleMemory>[];
+ for (final memory in allMemories) {
+ if (memory is PeopleMemory &&
+ (memory.isBirthday ?? false) &&
+ memory.personID == personID) {
+ personMemories.add(memory);
+ }
+ }
+ PeopleMemory? personMemory;
+ for (final memory in personMemories) {
+ if (memory.peopleMemoryType == PeopleMemoryType.youAndThem) {
+ personMemory = memory;
+ break; // breaking to prefer youAndThem over spotlight
+ }
+ if (memory.peopleMemoryType == PeopleMemoryType.spotlight) {
+ personMemory = memory;
+ }
+ }
+
+ if (personMemory == null) {
+ _logger.severe(
+ "Could not find person memory, routing to person page instead",
+ );
+ final person = await PersonService.instance.getPerson(personID);
+ if (person == null) {
+ _logger.severe("Person with ID $personID not found");
+ return;
+ }
+ await routeToPage(
+ context,
+ PeoplePage(
+ person: person,
+ searchResult: null,
+ ),
+ forceCustomPageRoute: true,
+ );
+ }
+ await routeToPage(
+ context,
+ FullScreenMemoryDataUpdater(
+ initialIndex: 0,
+ memories: personMemory!.memories,
+ child: FullScreenMemory(personMemory.title, 0),
+ ),
+ forceCustomPageRoute: true,
+ );
+ }
+
Future<void> toggleOnThisDayNotifications() async {
final oldValue = localSettings.isOnThisDayNotificationsEnabled;
await localSettings.setOnThisDayNotificationsEnabled(!oldValue);
diff --git a/mobile/lib/ui/tabs/home_widget.dart b/mobile/lib/ui/tabs/home_widget.dart
index 0b2ffa26ab..5e197c9253 100644
--- a/mobile/lib/ui/tabs/home_widget.dart
+++ b/mobile/lib/ui/tabs/home_widget.dart
@@ -864,8 +864,11 @@ class _HomeWidgetState extends State<HomeWidget> {
if (payload.toLowerCase().contains("onthisday")) {
// ignore: unawaited_futures
memoriesCacheService.goToOnThisDayMemory(context);
+ } else if (payload.toLowerCase().contains("birthday")) {
+ final personID = payload.substring("birthday_".length);
+ // ignore: unawaited_futures
+ memoriesCacheService.goToPersonMemory(context, personID);
} else {
- // TODO:lau (after mergin main): add another case here for birthday notifications
final collectionID = Uri.parse(payload).queryParameters["collectionID"];
if (collectionID != null) {
final collection = CollectionsService.instance