From 7d84ed3e8ba1675c4e48a481c323669a80f50e50 Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Thu, 27 Feb 2025 11:40:44 +0530 Subject: [PATCH] [mob][photos] Rename --- mobile/lib/models/memories_cache.dart | 53 +++++++++---------- .../lib/services/memories_cache_service.dart | 9 ++-- 2 files changed, 29 insertions(+), 33 deletions(-) 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 toShowMemories; - final List peopleShownLogs; - final List tripsShownLogs; + final List peopleShownLogs; + final List tripsShownLogs; MemoriesCache({ required this.toShowMemories, @@ -21,17 +19,16 @@ class MemoriesCache { factory MemoriesCache.fromJson(Map 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 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 json) { - return PeopleShownLogs( + factory PeopleShownLog.fromJson(Map json) { + return PeopleShownLog( json['personID'], peopleMemoryTypeFromString(json['peopleMemoryType']), json['lastTimeShown'], @@ -193,36 +190,36 @@ class PeopleShownLogs { }; } - static String encodeListToJson(List shownLogs) { + static String encodeListToJson(List shownLogs) { final jsonList = shownLogs.map((log) => log.toJson()).toList(); return jsonEncode(jsonList); } - static List decodeJsonToList(String jsonString) { + static List 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 json) { - return TripsShownLogs( + factory TripsShownLog.fromJson(Map json) { + return TripsShownLog( Location( latitude: json['location']['latitude'], longitude: json['location']['longitude'], @@ -241,13 +238,13 @@ class TripsShownLogs { }; } - static String encodeListToJson(List shownLogs) { + static String encodeListToJson(List shownLogs) { final jsonList = shownLogs.map((log) => log.toJson()).toList(); return jsonEncode(jsonList); } - static List decodeJsonToList(String jsonString) { + static List 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 toShowMemories = []; - final List peopleShownLogs = []; - final List tripsShownLogs = []; + final List peopleShownLogs = []; + final List 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)); } } }