Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] fix notification options switch logic

Priyanshu Dangare0ecae3cfe57f
diff --git a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
index 5d129e64b7..6f0e896ef0 100644
--- a/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/notification_settings_screen.dart
@@ -32,16 +32,26 @@ class _NotificationSettingsScreenState
bool Function() getValue,
Future<void> Function(bool value) setValue,
) async {
- final value = _hasPermission ? !getValue() : true;
+ final oldValue = _hasPermission && getValue();
- if (!_hasPermission &&
- (!await NotificationService.instance.requestPermissions(context) ||
- !mounted)) {
+ if (_hasPermission) {
+ await setValue(!oldValue);
+ if (mounted) setState(() {});
+ return;
+ }
+
+ final granted = await NotificationService.instance.requestPermissions(
+ context,
+ );
+
+ if (!granted) {
+ await setValue(false);
+ if (mounted) setState(() {});
return;
}
_hasPermission = true;
- await setValue(value);
+ await setValue(true);
if (mounted) setState(() {});
}