Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reduce logging

laurenspriem0a93e7e9471b
diff --git a/mobile/apps/photos/lib/services/activity/activity_service.dart b/mobile/apps/photos/lib/services/activity/activity_service.dart
index 4034d5a174..8a2d948b5e 100644
--- a/mobile/apps/photos/lib/services/activity/activity_service.dart
+++ b/mobile/apps/photos/lib/services/activity/activity_service.dart
@@ -296,8 +296,10 @@ class ActivityService {
final rituals = await _loadRituals();
rituals.removeWhere((r) => r.id == id);
await _persistRituals(rituals);
+ _logger.info("Clearing scheduled notifications for ritual $id (delete)");
await NotificationService.instance.clearAllScheduledNotifications(
containingPayload: "ritualId=$id",
+ logLines: false,
);
await refresh();
}
@@ -308,11 +310,15 @@ class ActivityService {
}
Future<void> _scheduleRitualNotifications(Ritual ritual) async {
+ _logger.info(
+ "Clearing scheduled notifications for ritual ${ritual.id} (save path)",
+ );
_logger.info(
"Scheduling ritual reminders for ritual ${ritual.id} (save path)",
);
await NotificationService.instance.clearAllScheduledNotifications(
containingPayload: ritual.id,
+ logLines: false,
);
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
diff --git a/mobile/apps/photos/lib/services/notification_service.dart b/mobile/apps/photos/lib/services/notification_service.dart
index 37f6fd381d..4962efcd11 100644
--- a/mobile/apps/photos/lib/services/notification_service.dart
+++ b/mobile/apps/photos/lib/services/notification_service.dart
@@ -220,29 +220,40 @@ class NotificationService {
Future<void> clearAllScheduledNotifications({
String? containingPayload,
+ bool logLines = true,
}) async {
try {
- _logger.info("Clearing all scheduled notifications");
+ if (logLines) {
+ _logger.info("Clearing all scheduled notifications");
+ }
final pending = await _notificationsPlugin.pendingNotificationRequests();
if (pending.isEmpty) {
- _logger.info("No pending notifications to clear");
+ if (logLines) {
+ _logger.info("No pending notifications to clear");
+ }
return;
}
for (final request in pending) {
if (containingPayload != null &&
!request.payload.toString().contains(containingPayload)) {
+ if (logLines) {
+ _logger.info(
+ "Skip clearing of notification with id: ${request.id} and payload: ${request.payload}",
+ );
+ }
+ continue;
+ }
+ if (logLines) {
_logger.info(
- "Skip clearing of notification with id: ${request.id} and payload: ${request.payload}",
+ "Clearing notification with id: ${request.id} and payload: ${request.payload}",
);
- continue;
}
- _logger.info(
- "Clearing notification with id: ${request.id} and payload: ${request.payload}",
- );
await _notificationsPlugin.cancel(request.id);
- _logger.info(
- "Cleared notification with id: ${request.id} and payload: ${request.payload}",
- );
+ if (logLines) {
+ _logger.info(
+ "Cleared notification with id: ${request.id} and payload: ${request.payload}",
+ );
+ }
}
} catch (e, s) {
_logger.severe("Something is wrong with scheduled notifications", e, s);