From ffbfd191e06a6e6f72af4b2f13d9a82a76532e7a Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Thu, 15 Jun 2023 07:11:57 +0200 Subject: [PATCH] neon: AppImplementation provide default getUnreadCounter neon: simplify AppImplementation.getUnreadCounter interface --- packages/neon/neon/lib/src/pages/home.dart | 3 ++- packages/neon/neon/lib/src/utils/app_implementation.dart | 2 +- packages/neon/neon_files/lib/neon_files.dart | 3 --- packages/neon/neon_news/lib/neon_news.dart | 2 +- packages/neon/neon_notes/lib/neon_notes.dart | 3 --- packages/neon/neon_notifications/lib/neon_notifications.dart | 3 +-- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 1e080866..b6984f94 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -461,7 +461,8 @@ class _HomePageState extends State { actions: [ if (notificationsAppImplementation.data != null) ...[ StreamBuilder( - stream: notificationsAppImplementation.data!.getUnreadCounter(_appsBloc), + stream: notificationsAppImplementation.data! + .getUnreadCounter(notificationsAppImplementation.data!.getBloc(account)), builder: (final context, final unreadCounterSnapshot) { final unreadCount = unreadCounterSnapshot.data ?? 0; return IconButton( diff --git a/packages/neon/neon/lib/src/utils/app_implementation.dart b/packages/neon/neon/lib/src/utils/app_implementation.dart index 961e5ca2..aa6ee3ee 100644 --- a/packages/neon/neon/lib/src/utils/app_implementation.dart +++ b/packages/neon/neon/lib/src/utils/app_implementation.dart @@ -37,7 +37,7 @@ abstract class AppImplementation? getUnreadCounter(final AppsBloc appsBloc); + BehaviorSubject? getUnreadCounter(final T bloc) => null; Widget get page; diff --git a/packages/neon/neon_files/lib/neon_files.dart b/packages/neon/neon_files/lib/neon_files.dart index 66a5c320..078b3504 100644 --- a/packages/neon/neon_files/lib/neon_files.dart +++ b/packages/neon/neon_files/lib/neon_files.dart @@ -63,7 +63,4 @@ class FilesApp extends AppImplementation { @override Widget get page => const FilesMainPage(); - - @override - BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => null; } diff --git a/packages/neon/neon_news/lib/neon_news.dart b/packages/neon/neon_news/lib/neon_news.dart index 030a11fc..31fe7a7b 100644 --- a/packages/neon/neon_news/lib/neon_news.dart +++ b/packages/neon/neon_news/lib/neon_news.dart @@ -71,5 +71,5 @@ class NewsApp extends AppImplementation { Widget get page => const NewsMainPage(); @override - BehaviorSubject getUnreadCounter(final AppsBloc appsBloc) => appsBloc.getAppBloc(this).unreadCounter; + BehaviorSubject getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter; } diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index 2ca34cfb..65543b61 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -60,7 +60,4 @@ class NotesApp extends AppImplementation { @override Widget get page => const NotesMainPage(); - - @override - BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => null; } diff --git a/packages/neon/neon_notifications/lib/neon_notifications.dart b/packages/neon/neon_notifications/lib/neon_notifications.dart index 83db56d7..d7fc163c 100644 --- a/packages/neon/neon_notifications/lib/neon_notifications.dart +++ b/packages/neon/neon_notifications/lib/neon_notifications.dart @@ -41,6 +41,5 @@ class NotificationsApp extends AppImplementation const NotificationsMainPage(); @override - BehaviorSubject getUnreadCounter(final AppsBloc appsBloc) => - appsBloc.getAppBloc(this).unreadCounter; + BehaviorSubject getUnreadCounter(final NotificationsBloc bloc) => bloc.unreadCounter; }