Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix redirect to person memory

laurenspriem97b3a3cb574e
diff --git a/mobile/apps/photos/lib/models/memories/memories_cache.dart b/mobile/apps/photos/lib/models/memories/memories_cache.dart
index 949107901d..f45282d30c 100644
--- a/mobile/apps/photos/lib/models/memories/memories_cache.dart
+++ b/mobile/apps/photos/lib/models/memories/memories_cache.dart
@@ -81,6 +81,8 @@ class ToShowMemory {
final String id;
final String? personID;
+ final String? personName;
+ final bool? isBirthday;
final PeopleMemoryType? peopleMemoryType;
final ClipMemoryType? clipMemoryType;
final Location? location;
@@ -107,6 +109,8 @@ class ToShowMemory {
this.id,
this.calculationTime, {
this.personID,
+ this.personName,
+ this.isBirthday,
this.peopleMemoryType,
this.clipMemoryType,
this.location,
@@ -124,11 +128,15 @@ class ToShowMemory {
factory ToShowMemory.fromSmartMemory(SmartMemory memory, DateTime calcTime) {
String? personID;
+ String? personName;
+ bool? isBirthday;
PeopleMemoryType? peopleMemoryType;
ClipMemoryType? clipMemoryType;
Location? location;
if (memory is PeopleMemory) {
personID = memory.personID;
+ personName = memory.personName;
+ isBirthday = memory.isBirthday;
peopleMemoryType = memory.peopleMemoryType;
} else if (memory is TripMemory) {
location = memory.location;
@@ -147,6 +155,8 @@ class ToShowMemory {
memory.id,
calcTime.microsecondsSinceEpoch,
personID: personID,
+ personName: personName,
+ isBirthday: isBirthday,
peopleMemoryType: peopleMemoryType,
clipMemoryType: clipMemoryType,
location: location,
@@ -163,6 +173,8 @@ class ToShowMemory {
json['id'] ?? newID(json['type'] as String),
json['calculationTime'],
personID: json['personID'],
+ isBirthday: json['isBirthday'],
+ personName: json['personName'],
peopleMemoryType: json['peopleMemoryType'] != null
? peopleMemoryTypeFromString(json['peopleMemoryType'])
: null,
@@ -188,6 +200,8 @@ class ToShowMemory {
'id': id,
'calculationTime': calculationTime,
'personID': personID,
+ 'isBirthday': isBirthday,
+ 'personName': personName,
'peopleMemoryType': peopleMemoryType?.toString().split('.').last,
'clipMemoryType': clipMemoryType?.toString().split('.').last,
'location': location != null
diff --git a/mobile/apps/photos/lib/models/memories/people_memory.dart b/mobile/apps/photos/lib/models/memories/people_memory.dart
index 83f6b1a363..fea9190302 100644
--- a/mobile/apps/photos/lib/models/memories/people_memory.dart
+++ b/mobile/apps/photos/lib/models/memories/people_memory.dart
@@ -108,6 +108,8 @@ class PeopleMemory extends SmartMemory {
this.peopleMemoryType,
this.personID,
this.personName, {
+ String? title,
+ String? id,
super.firstCreationTime,
super.lastCreationTime,
this.activity,
@@ -116,9 +118,10 @@ class PeopleMemory extends SmartMemory {
}) : super(
memories,
MemoryType.people,
- '',
+ title ?? '',
firstDateToShow,
lastDateToShow,
+ id: id,
);
PeopleMemory copyWith({
diff --git a/mobile/apps/photos/lib/services/memories_cache_service.dart b/mobile/apps/photos/lib/services/memories_cache_service.dart
index 51ea8710bb..9372322f84 100644
--- a/mobile/apps/photos/lib/services/memories_cache_service.dart
+++ b/mobile/apps/photos/lib/services/memories_cache_service.dart
@@ -241,20 +241,44 @@ class MemoriesCacheService {
for (final ToShowMemory memory in cache.toShowMemories) {
if (memory.shouldShowNow()) {
- final smartMemory = SmartMemory(
- memory.fileUploadedIDs
- .where((fileID) => minimalFileIdsToFile.containsKey(fileID))
- .map(
- (fileID) =>
- Memory.fromFile(minimalFileIdsToFile[fileID]!, seenTimes),
- )
- .toList(),
- memory.type,
- memory.title,
- memory.firstTimeToShow,
- memory.lastTimeToShow,
- id: memory.id,
- );
+ late final SmartMemory smartMemory;
+ if (memory.type == MemoryType.people) {
+ smartMemory = PeopleMemory(
+ memory.fileUploadedIDs
+ .where((fileID) => minimalFileIdsToFile.containsKey(fileID))
+ .map(
+ (fileID) => Memory.fromFile(
+ minimalFileIdsToFile[fileID]!,
+ seenTimes,
+ ),
+ )
+ .toList(),
+ memory.firstTimeToShow,
+ memory.lastTimeToShow,
+ memory.peopleMemoryType!,
+ memory.personID!,
+ memory.personName,
+ title: memory.title,
+ id: memory.id,
+ );
+ } else {
+ smartMemory = SmartMemory(
+ memory.fileUploadedIDs
+ .where((fileID) => minimalFileIdsToFile.containsKey(fileID))
+ .map(
+ (fileID) => Memory.fromFile(
+ minimalFileIdsToFile[fileID]!,
+ seenTimes,
+ ),
+ )
+ .toList(),
+ memory.type,
+ memory.title,
+ memory.firstTimeToShow,
+ memory.lastTimeToShow,
+ id: memory.id,
+ );
+ }
if (smartMemory.memories.isNotEmpty) {
memories.add(smartMemory);
}