From efc8f59c104bfb6f45904f819d52e724d166654b Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 29 Jul 2023 23:27:59 +0200 Subject: [PATCH] fix(neon): Hide useless push notifications popups --- .../neon/lib/src/utils/global_popups.dart | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/neon/neon/lib/src/utils/global_popups.dart b/packages/neon/neon/lib/src/utils/global_popups.dart index 4b73b3a0..58b12787 100644 --- a/packages/neon/neon/lib/src/utils/global_popups.dart +++ b/packages/neon/neon/lib/src/utils/global_popups.dart @@ -4,6 +4,7 @@ import 'package:neon/l10n/localizations.dart'; import 'package:neon/src/blocs/first_launch.dart'; import 'package:neon/src/blocs/next_push.dart'; import 'package:neon/src/pages/settings.dart'; +import 'package:neon/src/platform/platform.dart'; import 'package:neon/src/router.dart'; import 'package:neon/src/utils/global_options.dart'; import 'package:provider/provider.dart'; @@ -31,27 +32,31 @@ class GlobalPopups { final globalOptions = Provider.of(context, listen: false); final firstLaunchBloc = Provider.of(context, listen: false); final nextPushBloc = Provider.of(context, listen: false); + final platform = Provider.of(context, listen: false); firstLaunchBloc.onFirstLaunch.listen((final _) { - if (globalOptions.pushNotificationsEnabled.enabled) { - if (!context.mounted) { - return; - } - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications), - action: SnackBarAction( - label: AppLocalizations.of(context).settings, - onPressed: () { - const SettingsRoute(initialCategory: SettingsCageories.pushNotifications).go(context); - }, - ), - ), - ); + if (!platform.canUsePushNotifications || !globalOptions.pushNotificationsEnabled.enabled) { + return; } + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications), + action: SnackBarAction( + label: AppLocalizations.of(context).settings, + onPressed: () { + const SettingsRoute(initialCategory: SettingsCageories.pushNotifications).go(context); + }, + ), + ), + ); }); nextPushBloc.onNextPushSupported.listen((final _) async { + if (!platform.canUsePushNotifications || !globalOptions.pushNotificationsEnabled.enabled) { + return; + } + await showDialog( context: context, builder: (final context) => AlertDialog(