Skip to content

Commit

Permalink
fix: close client on bloc close
Browse files Browse the repository at this point in the history
  • Loading branch information
Xazin committed Mar 2, 2024
1 parent 39fe3f3 commit 6053ea6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ abstract class IGitHubService {
///
/// Returns [GitHubReleaseInfo] if the request is successful, otherwise returns null.
Future<GitHubReleaseInfo?> checkLatestGitHubRelease();

/// Disposes of any resources used by the service.
///
void dispose();
}

@freezed
Expand Down Expand Up @@ -81,4 +85,9 @@ class GitHubService implements IGitHubService {

return null;
}

@override
void dispose() {
_client.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:bloc/bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:package_info_plus/package_info_plus.dart';

part 'update_checker_bloc.freezed.dart';
part 'version_checker_bloc.freezed.dart';

class VersionCheckerBloc
extends Bloc<VersionCheckerEvent, VersionCheckerState> {
Expand Down Expand Up @@ -39,6 +39,12 @@ class VersionCheckerBloc
}

late final IGitHubService _gitHubService;

@override
Future<void> close() async {
_gitHubService.dispose();
return super.close();
}
}

@freezed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/startup/tasks/rust_sdk.dart';
import 'package:appflowy/workspace/application/update_checker/update_checker_bloc.dart';
import 'package:appflowy/workspace/application/version_checker/version_checker_bloc.dart';
import 'package:appflowy/workspace/presentation/home/toast.dart';
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
Expand Down

0 comments on commit 6053ea6

Please sign in to comment.