Browse Source

fix(neon,neon_files): properly dispose blocs

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/714/head
Nikolas Rimikis 1 year ago
parent
commit
f4289bbc0a
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 10
      packages/neon/neon/lib/neon.dart
  2. 1
      packages/neon/neon/lib/src/bloc/bloc.dart
  3. 4
      packages/neon/neon/lib/src/blocs/apps.dart
  4. 2
      packages/neon/neon/lib/src/blocs/login_check_account.dart
  5. 2
      packages/neon/neon/lib/src/blocs/login_check_server_status.dart
  6. 2
      packages/neon/neon/lib/src/blocs/login_flow.dart
  7. 5
      packages/neon/neon/lib/src/models/app_implementation.dart
  8. 2
      packages/neon/neon_files/lib/blocs/files.dart

10
packages/neon/neon/lib/neon.dart

@ -67,21 +67,31 @@ Future runNeon({
providers: [
Provider<GlobalOptions>(
create: (final _) => globalOptions,
dispose: (final _, final globalOptions) => globalOptions.dispose(),
),
Provider<AccountsBloc>(
create: (final _) => accountsBloc,
dispose: (final _, final accountsBloc) => accountsBloc.dispose(),
),
Provider<PushNotificationsBloc>(
create: (final _) => pushNotificationsBloc,
dispose: (final _, final pushNotificationsBloc) => pushNotificationsBloc.dispose(),
),
Provider<FirstLaunchBloc>(
create: (final _) => firstLaunchBloc,
dispose: (final _, final firstLaunchBloc) => firstLaunchBloc.dispose(),
),
Provider<NextPushBloc>(
create: (final _) => nextPushBloc,
dispose: (final _, final nextPushBloc) => nextPushBloc.dispose(),
),
Provider<Iterable<AppImplementation>>(
create: (final _) => appImplementations,
dispose: (final _, final appImplementations) {
for (final app in appImplementations) {
app.dispose();
}
},
),
Provider<PackageInfo>(
create: (final _) => packageInfo,

1
packages/neon/neon/lib/src/bloc/bloc.dart

@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:neon/src/utils/request_manager.dart';
abstract class Bloc {
@mustCallSuper
void dispose();
}

4
packages/neon/neon/lib/src/blocs/apps.dart

@ -164,9 +164,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
unawaited(openNotifications.close());
unawaited(appVersions.close());
for (final app in _allAppImplementations) {
app.dispose();
}
super.dispose();
}
@override

2
packages/neon/neon/lib/src/blocs/login_check_account.dart

@ -32,6 +32,8 @@ class LoginCheckAccountBloc extends InteractiveBloc
@override
void dispose() {
unawaited(state.close());
super.dispose();
}
@override

2
packages/neon/neon/lib/src/blocs/login_check_server_status.dart

@ -25,6 +25,8 @@ class LoginCheckServerStatusBloc extends InteractiveBloc
@override
void dispose() {
unawaited(state.close());
super.dispose();
}
@override

2
packages/neon/neon/lib/src/blocs/login_flow.dart

@ -34,6 +34,8 @@ class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, Logi
_cancelPollTimer();
unawaited(init.close());
unawaited(_resultController.close());
super.dispose();
}
@override

5
packages/neon/neon/lib/src/models/app_implementation.dart

@ -105,11 +105,10 @@ abstract class AppImplementation<T extends Bloc, R extends NextcloudAppOptions>
),
);
@mustCallSuper
void dispose() {
options.dispose();
for (final bloc in _blocs.values) {
bloc.dispose();
}
_blocs.disposeAll();
}
/// A custom theme that will be injected into the widget tree.

2
packages/neon/neon_files/lib/blocs/files.dart

@ -48,6 +48,8 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
options.uploadQueueParallelism.removeListener(_uploadParallelismListener);
options.downloadQueueParallelism.removeListener(_downloadParallelismListener);
super.dispose();
}
@override

Loading…
Cancel
Save