From 79760bf58b42c5b115cf9db09a2e5091fbaae2db Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 6 Oct 2023 08:32:35 +0200 Subject: [PATCH] refactor(neon): Cleanup push notifications bloc Signed-off-by: jld3103 --- packages/neon/neon/lib/neon.dart | 3 +-- .../neon/neon/lib/src/blocs/push_notifications.dart | 10 +--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/neon/neon/lib/neon.dart b/packages/neon/neon/lib/neon.dart index b28691c9..6bf60d46 100644 --- a/packages/neon/neon/lib/neon.dart +++ b/packages/neon/neon/lib/neon.dart @@ -51,7 +51,7 @@ Future runNeon({ ..addAccount(account) ..setActiveAccount(account); } - final pushNotificationsBloc = PushNotificationsBloc( + PushNotificationsBloc( accountsBloc, globalOptions, ); @@ -69,7 +69,6 @@ Future runNeon({ providers: [ NeonProvider.value(value: globalOptions), NeonProvider.value(value: accountsBloc), - NeonProvider.value(value: pushNotificationsBloc), NeonProvider.value(value: firstLaunchBloc), NeonProvider.value(value: nextPushBloc), Provider>( diff --git a/packages/neon/neon/lib/src/blocs/push_notifications.dart b/packages/neon/neon/lib/src/blocs/push_notifications.dart index 9571bb53..d8115d2a 100644 --- a/packages/neon/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/neon/lib/src/blocs/push_notifications.dart @@ -6,7 +6,6 @@ import 'package:meta/meta.dart'; import 'package:neon/src/bloc/bloc.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; -import 'package:neon/src/models/push_notification.dart'; import 'package:neon/src/platform/platform.dart'; import 'package:neon/src/settings/models/storage.dart'; import 'package:neon/src/utils/global_options.dart'; @@ -18,9 +17,7 @@ import 'package:unifiedpush/unifiedpush.dart'; abstract interface class PushNotificationsBlocEvents {} @internal -abstract interface class PushNotificationsBlocStates { - Stream get notifications; -} +abstract interface class PushNotificationsBlocStates {} @internal class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, PushNotificationsBlocStates { @@ -41,19 +38,14 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, late final _storage = const AppStorage(StorageKeys.notifications); final GlobalOptions _globalOptions; - final _notificationsController = StreamController(); StreamSubscription>? _accountsListener; @override void dispose() { - unawaited(_notificationsController.close()); unawaited(_accountsListener?.cancel()); _globalOptions.pushNotificationsEnabled.removeListener(_pushNotificationsEnabledListener); } - @override - late Stream notifications = _notificationsController.stream.asBroadcastStream(); - String _keyLastEndpoint(final Account account) => 'last-endpoint-${account.id}'; Future _pushNotificationsEnabledListener() async {