π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] fix issue in notification settings toggles
Priyanshu Dangaree7317e12253c
diff --git a/mobile/apps/photos/lib/services/notification_service.dart b/mobile/apps/photos/lib/services/notification_service.dartindex ddcea4eaa6..6ca510df2a 100644--- a/mobile/apps/photos/lib/services/notification_service.dart+++ b/mobile/apps/photos/lib/services/notification_service.dart@@ -166,10 +166,20 @@ class NotificationService {}Future<bool> requestPermissions(BuildContext context) async {- if (await _askPermissions(context)) {+ if (await hasGrantedPermissions()) {return true;}+ if (await _askPermissions()) {+ return true;+ }++ if (!context.mounted) {+ return false;+ }++ await _openNotificationSettings(context);+const interval = Duration(milliseconds: 500);const maxAttempts = 1000;@@ -184,23 +194,22 @@ class NotificationService {return false;}- Future<bool> _askPermissions(BuildContext context) async {+ Future<bool> _askPermissions() async {await _ensurePluginInitialized();- final granted = Platform.isIOS- ? await _notificationsPlugin- .resolvePlatformSpecificImplementation<- IOSFlutterLocalNotificationsPlugin- >()- ?.requestPermissions(sound: true, alert: true)- : await _notificationsPlugin- .resolvePlatformSpecificImplementation<- AndroidFlutterLocalNotificationsPlugin- >()- ?.requestNotificationsPermission();- if (granted == false && context.mounted) {- await _openNotificationSettings(context);- }- return granted ?? false;+ final granted =+ (Platform.isIOS+ ? await _notificationsPlugin+ .resolvePlatformSpecificImplementation<+ IOSFlutterLocalNotificationsPlugin+ >()+ ?.requestPermissions(sound: true, alert: true)+ : await _notificationsPlugin+ .resolvePlatformSpecificImplementation<+ AndroidFlutterLocalNotificationsPlugin+ >()+ ?.requestNotificationsPermission()) ??+ false;+ return granted;}Future<void> _openNotificationSettings(BuildContext context) async {diff --git a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dartindex 6f0e896ef0..f55ecbedf7 100644--- a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart@@ -45,8 +45,6 @@ class _NotificationSettingsScreenState);if (!granted) {- await setValue(false);- if (mounted) setState(() {});return;}@@ -77,7 +75,7 @@ class _NotificationSettingsScreenStateonChanged: () => _toggleWithPermission(service.shouldShowNotificationsForSharedPhotosAndAlbums,service.setShouldShowNotificationsForSharedPhotosAndAlbums,- ),+ ).ignore(),showStateIcon: false,),),@@ -93,7 +91,7 @@ class _NotificationSettingsScreenStateonChanged: () => _toggleWithPermission(service.shouldShowSocialNotifications,service.setShouldShowSocialNotifications,- ),+ ).ignore(),showStateIcon: false,),),@@ -110,7 +108,7 @@ class _NotificationSettingsScreenStateonChanged: () => _toggleWithPermission(() => localSettings.isOnThisDayNotificationsEnabled,memoriesCacheService.setOnThisDayNotifications,- ),+ ).ignore(),showStateIcon: false,),),@@ -127,7 +125,7 @@ class _NotificationSettingsScreenStateonChanged: () => _toggleWithPermission(() => localSettings.birthdayNotificationsEnabled,memoriesCacheService.setBirthdayNotifications,- ),+ ).ignore(),showStateIcon: false,),),