don't await on disable and add documentation and comments

This commit is contained in:
sneurlax 2023-09-12 15:47:39 -05:00
parent 53baad66b6
commit 6594e3c0cf
3 changed files with 17 additions and 2 deletions

@ -1 +1 @@
Subproject commit 0979ac52a783ff7b87669434b39385f27a27f952 Subproject commit 84ad84e07dee5b64828ad5ce380491b3aa798cc3

View file

@ -364,6 +364,13 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
); );
} }
/// Connect to the Tor network.
///
/// This method is called when the user taps the "Connect" button.
///
/// Throws an exception if the Tor service fails to start.
///
/// Returns a Future that completes when the Tor service has started.
Future<void> connect() async { Future<void> connect() async {
// Init the Tor service if it hasn't already been. // Init the Tor service if it hasn't already been.
ref.read(pTorService).init(); ref.read(pTorService).init();
@ -381,6 +388,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
); );
} }
// Update the UI.
setState(() { setState(() {
_networkStatus = TorConnectionStatus.connecting; _networkStatus = TorConnectionStatus.connecting;
}); });
@ -388,6 +396,13 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
return; return;
} }
/// Disconnect from the Tor network.
///
/// This method is called when the user taps the "Disconnect" button.
///
/// Throws an exception if the Tor service fails to stop.
///
/// Returns a Future that completes when the Tor service has stopped.
Future<void> disconnect() async { Future<void> disconnect() async {
// Stop the Tor service. // Stop the Tor service.
try { try {

View file

@ -121,7 +121,7 @@ class TorService {
// Stop the Tor service. // Stop the Tor service.
try { try {
await _tor!.disable(); _tor!.disable();
// no exception or error so we can (probably?) assume tor // no exception or error so we can (probably?) assume tor
// has started successfully // has started successfully
_enabled = false; _enabled = false;