Browse Source

neon: Fix theme switching when switching accounts

pull/318/head
jld3103 2 years ago
parent
commit
6f965563de
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 14
      packages/neon/neon/lib/src/blocs/accounts.dart
  2. 1
      packages/neon/neon/lib/src/pages/home.dart
  3. 14
      packages/neon/neon/lib/src/utils/bloc.dart

14
packages/neon/neon/lib/src/blocs/accounts.dart

@ -63,12 +63,10 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
void dispose() { void dispose() {
unawaited(activeAccount.close()); unawaited(activeAccount.close());
unawaited(accounts.close()); unawaited(accounts.close());
for (final bloc in _userDetailsBlocs.values) { _appsBlocs.disposeAll();
bloc.dispose(); _capabilitiesBlocs.disposeAll();
} _userDetailsBlocs.disposeAll();
for (final bloc in _userStatusBlocs.values) { _userStatusBlocs.disposeAll();
bloc.dispose();
}
for (final options in _accountsOptions.values) { for (final options in _accountsOptions.values) {
options.dispose(); options.dispose();
} }
@ -166,7 +164,9 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
CapabilitiesBloc getCapabilitiesBloc(final Account account) { CapabilitiesBloc getCapabilitiesBloc(final Account account) {
if (_capabilitiesBlocs[account.id] != null) { if (_capabilitiesBlocs[account.id] != null) {
return _capabilitiesBlocs[account.id]!; final bloc = _capabilitiesBlocs[account.id]!;
unawaited(bloc.refresh());
return bloc;
} }
return _capabilitiesBlocs[account.id] = CapabilitiesBloc( return _capabilitiesBlocs[account.id] = CapabilitiesBloc(

1
packages/neon/neon/lib/src/pages/home.dart

@ -176,7 +176,6 @@ class _HomePageState extends State<HomePage> {
@override @override
void dispose() { void dispose() {
_capabilitiesBloc.dispose();
drawerScrollController.dispose(); drawerScrollController.dispose();
super.dispose(); super.dispose();
} }

14
packages/neon/neon/lib/src/utils/bloc.dart

@ -40,3 +40,17 @@ abstract class InteractiveBloc extends Bloc {
} }
} }
} }
extension DisposeableIterableBloc on Iterable<Bloc> {
void disposeAll() {
for (final bloc in this) {
bloc.dispose();
}
}
}
extension DisposeableMapBloc on Map<dynamic, Bloc> {
void disposeAll() {
values.disposeAll();
}
}

Loading…
Cancel
Save