Skip to content

armgit / ente

Public Imported from GitHub
0

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

Assign IDs to memories

laurenspriem476fe1b62477
diff --git a/mobile/lib/models/memories/memories_cache.dart b/mobile/lib/models/memories/memories_cache.dart
index 7a5ba47507..10c3490efb 100644
--- a/mobile/lib/models/memories/memories_cache.dart
+++ b/mobile/lib/models/memories/memories_cache.dart
@@ -1,5 +1,6 @@
import "dart:convert";
+import "package:photos/models/base/id.dart";
import "package:photos/models/base_location.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/location/location.dart";
@@ -83,6 +84,7 @@ class ToShowMemory {
final int firstTimeToShow;
final int lastTimeToShow;
final int calculationTime;
+ final String id;
final String? personID;
final PeopleMemoryType? peopleMemoryType;
@@ -108,6 +110,7 @@ class ToShowMemory {
this.type,
this.firstTimeToShow,
this.lastTimeToShow,
+ this.id,
this.calculationTime, {
this.personID,
this.peopleMemoryType,
@@ -147,6 +150,7 @@ class ToShowMemory {
memory.type,
memory.firstDateToShow,
memory.lastDateToShow,
+ memory.id!,
calcTime.microsecondsSinceEpoch,
personID: personID,
peopleMemoryType: peopleMemoryType,
@@ -163,6 +167,7 @@ class ToShowMemory {
json['firstTimeToShow'],
json['lastTimeToShow'],
json['calculationTime'],
+ json['id'] ?? newID(json['type'] as String),
personID: json['personID'],
peopleMemoryType: json['peopleMemoryType'] != null
? peopleMemoryTypeFromString(json['peopleMemoryType'])
@@ -186,6 +191,7 @@ class ToShowMemory {
'type': type.toString().split('.').last,
'firstTimeToShow': firstTimeToShow,
'lastTimeToShow': lastTimeToShow,
+ 'id': id,
'calculationTime': calculationTime,
'personID': personID,
'peopleMemoryType': peopleMemoryType?.toString().split('.').last,
diff --git a/mobile/lib/models/memories/smart_memory.dart b/mobile/lib/models/memories/smart_memory.dart
index 74b666cf66..52ce8fbf64 100644
--- a/mobile/lib/models/memories/smart_memory.dart
+++ b/mobile/lib/models/memories/smart_memory.dart
@@ -1,4 +1,5 @@
import "package:photos/generated/l10n.dart";
+import "package:photos/models/base/id.dart";
import "package:photos/models/memories/memory.dart";
enum MemoryType {
@@ -35,6 +36,7 @@ class SmartMemory {
String title;
int firstDateToShow;
int lastDateToShow;
+ late final String id;
int? firstCreationTime;
int? lastCreationTime;
@@ -45,9 +47,12 @@ class SmartMemory {
this.title,
this.firstDateToShow,
this.lastDateToShow, {
+ String? id,
this.firstCreationTime,
this.lastCreationTime,
- });
+ }) {
+ this.id = id ?? newID(type.name);
+ }
bool get notForShow => firstDateToShow == 0 && lastDateToShow == 0;
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dart
index 83c44bc798..bb8f8d2042 100644
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@ -313,6 +313,7 @@ class MemoriesCacheService {
memory.title,
memory.firstTimeToShow,
memory.lastTimeToShow,
+ id: memory.id,
);
if (smartMemory.memories.isNotEmpty) {
memories.add(smartMemory);