Skip to content

armgit / ente

Public Imported from GitHub
0

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

Extra logging for notification schedule

laurenspriem31baca4bb93e
diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
index c55943bd34..0c3e1dbfe1 100644
--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
@@ -1051,17 +1051,45 @@ class RemoteSyncService {
);
final s = await LanguageService.locals;
// ignore: unawaited_futures
- NotificationService.instance.showNotification(
- collection!.displayName,
- totalCount.toString() + s.newPhotosEmoji,
- channelID: "collection:" + collectionID.toString(),
+ _showNotificationSafely(
+ title: collection!.displayName,
+ message: "$totalCount${s.newPhotosEmoji}",
+ channelID: "collection:$collectionID",
channelName: collection.displayName,
- payload: "ente://collection/?collectionID=" + collectionID.toString(),
+ payload: "ente://collection/?collectionID=$collectionID",
+ context: 'collection=$collectionID',
);
}
}
}
+ Future<void> _showNotificationSafely({
+ required String title,
+ required String message,
+ int? id,
+ required String channelID,
+ required String channelName,
+ required String payload,
+ required String context,
+ }) async {
+ try {
+ await NotificationService.instance.showNotification(
+ title,
+ message,
+ channelID: channelID,
+ channelName: channelName,
+ payload: payload,
+ id: id,
+ );
+ } catch (e, stackTrace) {
+ _logger.warning(
+ "Failed to show notification ($context)",
+ e,
+ stackTrace,
+ );
+ }
+ }
+
/// Syncs social data and triggers notifications if needed.
Future<void> _socialSync() async {
try {
@@ -1230,19 +1258,29 @@ class RemoteSyncService {
if (fileID == null) {
continue;
}
- final title = await _getSocialNotificationTitle(candidate);
- await NotificationService.instance.showNotification(
- title,
- _getSocialNotificationBody(candidate.type, s),
- channelID: "social_activity",
- channelName: "Activity",
- payload: _buildSocialNotificationPayload(candidate),
- id: _buildSocialNotificationId(
- candidate.collectionID,
- fileID,
- _notificationGroupForType(candidate.type),
- ),
- );
+ try {
+ final title = await _getSocialNotificationTitle(candidate);
+ await _showNotificationSafely(
+ title: title,
+ message: _getSocialNotificationBody(candidate.type, s),
+ channelID: "social_activity",
+ channelName: "Activity",
+ payload: _buildSocialNotificationPayload(candidate),
+ id: _buildSocialNotificationId(
+ candidate.collectionID,
+ fileID,
+ _notificationGroupForType(candidate.type),
+ ),
+ context:
+ 'social type=${candidate.type.name} collection=${candidate.collectionID} file=$fileID',
+ );
+ } catch (e, stackTrace) {
+ _logger.warning(
+ "Failed to prepare social notification",
+ e,
+ stackTrace,
+ );
+ }
}
await _prefs.setInt(
kLastSocialActivityNotificationTime,