Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Rename

laurenspriem7d84ed3e8ba1
diff --git a/mobile/lib/models/memories_cache.dart b/mobile/lib/models/memories_cache.dart
index 246ccb1eaa..32b14416e4 100644
--- a/mobile/lib/models/memories_cache.dart
+++ b/mobile/lib/models/memories_cache.dart
@@ -1,5 +1,3 @@
-
-
import "dart:convert";
import "package:photos/models/location/location.dart";
@@ -9,8 +7,8 @@ import "package:photos/models/trip_memory.dart";
class MemoriesCache {
final List<ToShowMemory> toShowMemories;
- final List<PeopleShownLogs> peopleShownLogs;
- final List<TripsShownLogs> tripsShownLogs;
+ final List<PeopleShownLog> peopleShownLogs;
+ final List<TripsShownLog> tripsShownLogs;
MemoriesCache({
required this.toShowMemories,
@@ -21,17 +19,16 @@ class MemoriesCache {
factory MemoriesCache.fromJson(Map<String, dynamic> json) {
return MemoriesCache(
toShowMemories: ToShowMemory.decodeJsonToList(json['toShowMemories']),
- peopleShownLogs:
- PeopleShownLogs.decodeJsonToList(json['peopleShownLogs']),
- tripsShownLogs: TripsShownLogs.decodeJsonToList(json['tripsShownLogs']),
+ peopleShownLogs: PeopleShownLog.decodeJsonToList(json['peopleShownLogs']),
+ tripsShownLogs: TripsShownLog.decodeJsonToList(json['tripsShownLogs']),
);
}
Map<String, dynamic> toJson() {
return {
'toShowMemories': ToShowMemory.encodeListToJson(toShowMemories),
- 'peopleShownLogs': PeopleShownLogs.encodeListToJson(peopleShownLogs),
- 'tripsShownLogs': TripsShownLogs.encodeListToJson(tripsShownLogs),
+ 'peopleShownLogs': PeopleShownLog.encodeListToJson(peopleShownLogs),
+ 'tripsShownLogs': TripsShownLog.encodeListToJson(tripsShownLogs),
};
}
@@ -153,32 +150,32 @@ class ToShowMemory {
}
}
-class PeopleShownLogs {
+class PeopleShownLog {
final String personID;
final PeopleMemoryType peopleMemoryType;
final int lastTimeShown;
- PeopleShownLogs(
+ PeopleShownLog(
this.personID,
this.peopleMemoryType,
this.lastTimeShown,
);
- factory PeopleShownLogs.fromOldCacheMemory(ToShowMemory memory) {
+ factory PeopleShownLog.fromOldCacheMemory(ToShowMemory memory) {
assert(
memory.type == MemoryType.people &&
memory.personID != null &&
memory.peopleMemoryType != null,
);
- return PeopleShownLogs(
+ return PeopleShownLog(
memory.personID!,
memory.peopleMemoryType!,
memory.lastTimeToShow,
);
}
- factory PeopleShownLogs.fromJson(Map<String, dynamic> json) {
- return PeopleShownLogs(
+ factory PeopleShownLog.fromJson(Map<String, dynamic> json) {
+ return PeopleShownLog(
json['personID'],
peopleMemoryTypeFromString(json['peopleMemoryType']),
json['lastTimeShown'],
@@ -193,36 +190,36 @@ class PeopleShownLogs {
};
}
- static String encodeListToJson(List<PeopleShownLogs> shownLogs) {
+ static String encodeListToJson(List<PeopleShownLog> shownLogs) {
final jsonList = shownLogs.map((log) => log.toJson()).toList();
return jsonEncode(jsonList);
}
- static List<PeopleShownLogs> decodeJsonToList(String jsonString) {
+ static List<PeopleShownLog> decodeJsonToList(String jsonString) {
final jsonList = jsonDecode(jsonString) as List;
- return jsonList.map((json) => PeopleShownLogs.fromJson(json)).toList();
+ return jsonList.map((json) => PeopleShownLog.fromJson(json)).toList();
}
}
-class TripsShownLogs {
+class TripsShownLog {
final Location location;
final int lastTimeShown;
- TripsShownLogs(
+ TripsShownLog(
this.location,
this.lastTimeShown,
);
- factory TripsShownLogs.fromOldCacheMemory(ToShowMemory memory) {
+ factory TripsShownLog.fromOldCacheMemory(ToShowMemory memory) {
assert(memory.type == MemoryType.trips && memory.location != null);
- return TripsShownLogs(
+ return TripsShownLog(
memory.location!,
memory.lastTimeToShow,
);
}
- factory TripsShownLogs.fromJson(Map<String, dynamic> json) {
- return TripsShownLogs(
+ factory TripsShownLog.fromJson(Map<String, dynamic> json) {
+ return TripsShownLog(
Location(
latitude: json['location']['latitude'],
longitude: json['location']['longitude'],
@@ -241,13 +238,13 @@ class TripsShownLogs {
};
}
- static String encodeListToJson(List<TripsShownLogs> shownLogs) {
+ static String encodeListToJson(List<TripsShownLog> shownLogs) {
final jsonList = shownLogs.map((log) => log.toJson()).toList();
return jsonEncode(jsonList);
}
- static List<TripsShownLogs> decodeJsonToList(String jsonString) {
+ static List<TripsShownLog> decodeJsonToList(String jsonString) {
final jsonList = jsonDecode(jsonString) as List;
- return jsonList.map((json) => TripsShownLogs.fromJson(json)).toList();
+ return jsonList.map((json) => TripsShownLog.fromJson(json)).toList();
}
-}
\ No newline at end of file
+}
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dart
index a6b8204641..40a3b565af 100644
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@ -160,8 +160,8 @@ class MemoriesCacheService {
MemoriesCache? oldCache,
) {
final List<ToShowMemory> toShowMemories = [];
- final List<PeopleShownLogs> peopleShownLogs = [];
- final List<TripsShownLogs> tripsShownLogs = [];
+ final List<PeopleShownLog> peopleShownLogs = [];
+ final List<TripsShownLog> tripsShownLogs = [];
for (final memory in memories) {
if (memory.hasShowTime()) {
toShowMemories.add(ToShowMemory.fromSmartMemory(memory));
@@ -180,8 +180,7 @@ class MemoriesCacheService {
(person.personID == oldMemory.personID) &&
(person.peopleMemoryType == oldMemory.peopleMemoryType),
)) {
- peopleShownLogs
- .add(PeopleShownLogs.fromOldCacheMemory(oldMemory));
+ peopleShownLogs.add(PeopleShownLog.fromOldCacheMemory(oldMemory));
}
} else if (oldMemory.type == MemoryType.trips) {
if (!tripsShownLogs.any(
@@ -191,7 +190,7 @@ class MemoriesCacheService {
10.0,
),
)) {
- tripsShownLogs.add(TripsShownLogs.fromOldCacheMemory(oldMemory));
+ tripsShownLogs.add(TripsShownLog.fromOldCacheMemory(oldMemory));
}
}
}