Browse Source

Merge pull request #318 from provokateurin/fix/theme-switching

neon: Fix theme switching when switching accounts
pull/320/head
Kate 2 years ago committed by GitHub
parent
commit
cc83acafc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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() {
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(

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

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