Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix duplicate notification issue

laurenspriemca8f31086846
diff --git a/mobile/lib/models/memories/memories_cache.dart b/mobile/lib/models/memories/memories_cache.dart
index baaca92d3f..8257224fe7 100644
--- a/mobile/lib/models/memories/memories_cache.dart
+++ b/mobile/lib/models/memories/memories_cache.dart
@@ -101,7 +101,7 @@ class ToShowMemory {
final relevantForNow = now >= firstTimeToShow && now < lastTimeToShow;
final calculatedForNow = (now >= calculationTime) &&
(now < calculationTime + kMemoriesUpdateFrequency.inMicroseconds);
- return relevantForNow && calculatedForNow;
+ return relevantForNow && (calculatedForNow || type == MemoryType.onThisDay);
}
ToShowMemory(
diff --git a/mobile/lib/services/memories_cache_service.dart b/mobile/lib/services/memories_cache_service.dart
index 2ef1cfc6ba..07327d5cbf 100644
--- a/mobile/lib/services/memories_cache_service.dart
+++ b/mobile/lib/services/memories_cache_service.dart
@@ -560,6 +560,36 @@ class MemoriesCacheService {
);
}
+ Future<void> goToOnThisDayMemory(BuildContext context) async {
+ final allMemories = await getMemories();
+ if (allMemories.isEmpty) return;
+ int memoryIdx = 0;
+ bool found = false;
+ memoryLoop:
+ for (final memory in allMemories) {
+ if (memory.type == MemoryType.onThisDay) {
+ found = true;
+ break memoryLoop;
+ }
+ memoryIdx++;
+ }
+ if (!found) {
+ _logger.warning(
+ "Could not find onThisDay memory",
+ );
+ return;
+ }
+ await routeToPage(
+ context,
+ FullScreenMemoryDataUpdater(
+ initialIndex: 0,
+ memories: allMemories[memoryIdx].memories,
+ child: FullScreenMemory(allMemories[memoryIdx].title, 0),
+ ),
+ forceCustomPageRoute: true,
+ );
+ }
+
Future<MemoriesCache?> _readCacheFromDisk() async {
_logger.info("Reading memories cache result from disk");
final file = File(await _getCachePath());
diff --git a/mobile/lib/services/smart_memories_service.dart b/mobile/lib/services/smart_memories_service.dart
index 4593a0c63c..fecdebeae0 100644
--- a/mobile/lib/services/smart_memories_service.dart
+++ b/mobile/lib/services/smart_memories_service.dart
@@ -1630,7 +1630,7 @@ class SmartMemoriesService {
final List<OnThisDayMemory> memoryResults = [];
if (allFiles.isEmpty) return [];
- final daysToCompute = kMemoriesUpdateFrequency.inDays + 1;
+ final daysToCompute = kMemoriesUpdateFrequency.inDays;
final currentYear = currentTime.year;
final currentMonth = currentTime.month;
final currentDay = currentTime.day;
diff --git a/mobile/lib/ui/tabs/home_widget.dart b/mobile/lib/ui/tabs/home_widget.dart
index 9cc84fea1f..7414637e70 100644
--- a/mobile/lib/ui/tabs/home_widget.dart
+++ b/mobile/lib/ui/tabs/home_widget.dart
@@ -863,10 +863,7 @@ class _HomeWidgetState extends State<HomeWidget> {
debugPrint('notification payload: $payload');
if (payload.toLowerCase().contains("onthisday")) {
// ignore: unawaited_futures
- memoriesCacheService.goToMemoryFromMemoryID(
- context,
- payload,
- );
+ memoriesCacheService.goToOnThisDayMemory(context);
} else {
final collectionID = Uri.parse(payload).queryParameters["collectionID"];
if (collectionID != null) {