π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Consolidate social notification toggles into a single setting
ashilkn4a242b25e497
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 22bc8be498..6e1861c8f7 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -640,12 +640,8 @@"notifications": "Notifications","sharedPhotoNotifications": "New shared photos","sharedPhotoNotificationsExplanation": "Receive notifications when someone adds a photo to a shared album that you're a part of",- "commentNotifications": "Comments",- "commentNotificationsExplanation": "Receive notifications when someone comments on your shared photos",- "likeNotifications": "Likes",- "likeNotificationsExplanation": "Receive notifications when someone likes your photos",- "replyNotifications": "Replies",- "replyNotificationsExplanation": "Receive notifications when someone replies to your comments",+ "socialNotifications": "Social",+ "socialNotificationsExplanation": "Receive notifications for likes and comments on your photos, and for replies to your comments","advanced": "Advanced","general": "General","security": "Security",diff --git a/mobile/apps/photos/lib/services/notification_service.dart b/mobile/apps/photos/lib/services/notification_service.dartindex 32bb54c3b9..99f959b37e 100644--- a/mobile/apps/photos/lib/services/notification_service.dart+++ b/mobile/apps/photos/lib/services/notification_service.dart@@ -16,12 +16,8 @@ class NotificationService {"notification_permission_granted";static const String keyShouldShowNotificationsForSharedPhotos ="notifications_enabled_shared_photos";- static const String keyShouldShowCommentNotifications =- "notifications_enabled_social_comments";- static const String keyShouldShowLikeNotifications =- "notifications_enabled_social_likes";- static const String keyShouldShowReplyNotifications =- "notifications_enabled_social_replies";+ static const String keyShouldShowSocialNotifications =+ "notifications_enabled_social";NotificationService._privateConstructor();@@ -193,38 +189,14 @@ class NotificationService {);}- bool shouldShowCommentNotifications() {- final result = _preferences.getBool(keyShouldShowCommentNotifications);+ bool shouldShowSocialNotifications() {+ final result = _preferences.getBool(keyShouldShowSocialNotifications);return result ?? true;}- Future<void> setShouldShowCommentNotifications(bool value) {+ Future<void> setShouldShowSocialNotifications(bool value) {return _preferences.setBool(- keyShouldShowCommentNotifications,- value,- );- }-- bool shouldShowLikeNotifications() {- final result = _preferences.getBool(keyShouldShowLikeNotifications);- return result ?? true;- }-- Future<void> setShouldShowLikeNotifications(bool value) {- return _preferences.setBool(- keyShouldShowLikeNotifications,- value,- );- }-- bool shouldShowReplyNotifications() {- final result = _preferences.getBool(keyShouldShowReplyNotifications);- return result ?? true;- }-- Future<void> setShouldShowReplyNotifications(bool value) {- return _preferences.setBool(- keyShouldShowReplyNotifications,+ keyShouldShowSocialNotifications,value,);}diff --git a/mobile/apps/photos/lib/services/social_notification_coordinator.dart b/mobile/apps/photos/lib/services/social_notification_coordinator.dartindex 0194238708..74af0d27e7 100644--- a/mobile/apps/photos/lib/services/social_notification_coordinator.dart+++ b/mobile/apps/photos/lib/services/social_notification_coordinator.dart@@ -80,9 +80,7 @@ class SocialNotificationCoordinator {bool _shouldShowSocialNotifications(SharedPreferences prefs) {return prefs.containsKey(kIsFirstRemoteSyncDoneKey) &&- (NotificationService.instance.shouldShowCommentNotifications() ||- NotificationService.instance.shouldShowLikeNotifications() ||- NotificationService.instance.shouldShowReplyNotifications());+ NotificationService.instance.shouldShowSocialNotifications();}int _getCutoffTime(SharedPreferences prefs) {@@ -116,12 +114,6 @@ class SocialNotificationCoordinator {final hiddenCollectionIds = _collectionsService.getHiddenCollectionIds();final latestByKey = <String, _SocialActivityCandidate>{};- final bool enableCommentNotifications =- NotificationService.instance.shouldShowCommentNotifications();- final bool enableLikeNotifications =- NotificationService.instance.shouldShowLikeNotifications();- final bool enableReplyNotifications =- NotificationService.instance.shouldShowReplyNotifications();void considerCandidate(_SocialActivityCandidate candidate) {if (!_isSocialNotificationEnabledForType(candidate.type)) {@@ -147,12 +139,10 @@ class SocialNotificationCoordinator {final db = SocialDB.instance;- final List<Comment> fileComments = enableCommentNotifications- ? await db.getCommentsOnFilesSince(- excludeUserID: userID,- sinceTime: cutoffTime,- )- : <Comment>[];+ final List<Comment> fileComments = await db.getCommentsOnFilesSince(+ excludeUserID: userID,+ sinceTime: cutoffTime,+ );for (final comment in fileComments) {considerCandidate(_SocialActivityCandidate(@@ -167,18 +157,14 @@ class SocialNotificationCoordinator {);}- final List<Comment> replies = enableReplyNotifications- ? await db.getRepliesToUserCommentsSince(- targetUserID: userID,- sinceTime: cutoffTime,- )- : <Comment>[];- final List<Reaction> photoLikes = enableLikeNotifications- ? await db.getReactionsOnFilesSince(- excludeUserID: userID,- sinceTime: cutoffTime,- )- : <Reaction>[];+ final List<Comment> replies = await db.getRepliesToUserCommentsSince(+ targetUserID: userID,+ sinceTime: cutoffTime,+ );+ final List<Reaction> photoLikes = await db.getReactionsOnFilesSince(+ excludeUserID: userID,+ sinceTime: cutoffTime,+ );final repliesNeedingOwnerCheck = <Comment>[];final fileIDsNeedingOwnership = <int>{};@@ -301,14 +287,12 @@ class SocialNotificationCoordinator {bool _isSocialNotificationEnabledForType(FeedItemType type) {switch (type) {case FeedItemType.comment:- return NotificationService.instance.shouldShowCommentNotifications();case FeedItemType.reply:- return NotificationService.instance.shouldShowReplyNotifications();case FeedItemType.photoLike:- return NotificationService.instance.shouldShowLikeNotifications();+ return true;case FeedItemType.commentLike:case FeedItemType.replyLike:- return false; // Currently not notifying for comment/reply likes+ return false;}}diff --git a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dartindex 75af0df46f..1b60e8bb6a 100644--- a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart@@ -81,21 +81,20 @@ class NotificationSettingsScreen extends StatelessWidget {),),MenuItemWidgetNew(- title:- AppLocalizations.of(context).commentNotifications,+ title: AppLocalizations.of(context).socialNotifications,trailingWidget: ToggleSwitchWidget(value: () =>NotificationService.instance.hasGrantedPermissions() &&NotificationService.instance- .shouldShowCommentNotifications(),+ .shouldShowSocialNotifications(),onChanged: () async {await NotificationService.instance.requestPermissions();await NotificationService.instance- .setShouldShowCommentNotifications(+ .setShouldShowSocialNotifications(!NotificationService.instance- .shouldShowCommentNotifications(),+ .shouldShowSocialNotifications(),);},),@@ -109,73 +108,7 @@ class NotificationSettingsScreen extends StatelessWidget {),child: Text(AppLocalizations.of(context)- .commentNotificationsExplanation,- style: textTheme.mini- .copyWith(color: colorScheme.textMuted),- ),- ),- MenuItemWidgetNew(- title: AppLocalizations.of(context).likeNotifications,- trailingWidget: ToggleSwitchWidget(- value: () =>- NotificationService.instance- .hasGrantedPermissions() &&- NotificationService.instance- .shouldShowLikeNotifications(),- onChanged: () async {- await NotificationService.instance- .requestPermissions();- await NotificationService.instance- .setShouldShowLikeNotifications(- !NotificationService.instance- .shouldShowLikeNotifications(),- );- },- ),- ),- Padding(- padding: const EdgeInsets.only(- left: 16,- right: 16,- top: 8,- bottom: 16,- ),- child: Text(- AppLocalizations.of(context)- .likeNotificationsExplanation,- style: textTheme.mini- .copyWith(color: colorScheme.textMuted),- ),- ),- MenuItemWidgetNew(- title: AppLocalizations.of(context).replyNotifications,- trailingWidget: ToggleSwitchWidget(- value: () =>- NotificationService.instance- .hasGrantedPermissions() &&- NotificationService.instance- .shouldShowReplyNotifications(),- onChanged: () async {- await NotificationService.instance- .requestPermissions();- await NotificationService.instance- .setShouldShowReplyNotifications(- !NotificationService.instance- .shouldShowReplyNotifications(),- );- },- ),- ),- Padding(- padding: const EdgeInsets.only(- left: 16,- right: 16,- top: 8,- bottom: 16,- ),- child: Text(- AppLocalizations.of(context)- .replyNotificationsExplanation,+ .socialNotificationsExplanation,style: textTheme.mini.copyWith(color: colorScheme.textMuted),),diff --git a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dartindex 5afe8fd817..22c854287a 100644--- a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart+++ b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart@@ -451,48 +451,21 @@ class SettingsSearchRegistry {keywords: ["shared", "notifications", "shares"],),SettingsSearchItem(- title: l10n.commentNotifications,+ title: l10n.socialNotifications,subtitle: l10n.notifications,sectionPath: l10n.notifications,icon: HugeIcons.strokeRoundedNotification01,routeBuilder: (_) => const NotificationSettingsScreen(),isSubPage: true,keywords: [+ "social","comment","comments",- "social",- "notifications",- "notification",- ],- ),- SettingsSearchItem(- title: l10n.likeNotifications,- subtitle: l10n.notifications,- sectionPath: l10n.notifications,- icon: HugeIcons.strokeRoundedNotification01,- routeBuilder: (_) => const NotificationSettingsScreen(),- isSubPage: true,- keywords: ["like","likes",- "social",- "notifications",- "notification",- ],- ),- SettingsSearchItem(- title: l10n.replyNotifications,- subtitle: l10n.notifications,- sectionPath: l10n.notifications,- icon: HugeIcons.strokeRoundedNotification01,- routeBuilder: (_) => const NotificationSettingsScreen(),- isSubPage: true,- keywords: ["reply","replies",- "social","notifications",- "notification",],),SettingsSearchItem(