diff --git a/packages/neon/neon/lib/src/blocs/accounts.dart b/packages/neon/neon/lib/src/blocs/accounts.dart index 63fcf732..43e1ba52 100644 --- a/packages/neon/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/neon/lib/src/blocs/accounts.dart @@ -63,12 +63,10 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState void dispose() { unawaited(activeAccount.close()); unawaited(accounts.close()); - for (final bloc in _userDetailsBlocs.values) { - bloc.dispose(); - } - for (final bloc in _userStatusBlocs.values) { - bloc.dispose(); - } + _appsBlocs.disposeAll(); + _capabilitiesBlocs.disposeAll(); + _userDetailsBlocs.disposeAll(); + _userStatusBlocs.disposeAll(); for (final options in _accountsOptions.values) { options.dispose(); } @@ -166,7 +164,9 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState CapabilitiesBloc getCapabilitiesBloc(final Account account) { if (_capabilitiesBlocs[account.id] != null) { - return _capabilitiesBlocs[account.id]!; + final bloc = _capabilitiesBlocs[account.id]!; + unawaited(bloc.refresh()); + return bloc; } return _capabilitiesBlocs[account.id] = CapabilitiesBloc( diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 54dc64eb..0499c322 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -176,7 +176,6 @@ class _HomePageState extends State { @override void dispose() { - _capabilitiesBloc.dispose(); drawerScrollController.dispose(); super.dispose(); } diff --git a/packages/neon/neon/lib/src/utils/bloc.dart b/packages/neon/neon/lib/src/utils/bloc.dart index 8df2828b..bf03d890 100644 --- a/packages/neon/neon/lib/src/utils/bloc.dart +++ b/packages/neon/neon/lib/src/utils/bloc.dart @@ -40,3 +40,17 @@ abstract class InteractiveBloc extends Bloc { } } } + +extension DisposeableIterableBloc on Iterable { + void disposeAll() { + for (final bloc in this) { + bloc.dispose(); + } + } +} + +extension DisposeableMapBloc on Map { + void disposeAll() { + values.disposeAll(); + } +}