mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
remove tor service status getter
This commit is contained in:
parent
3e9a225470
commit
cf27dd9252
3 changed files with 16 additions and 24 deletions
|
@ -72,7 +72,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
_torConnectionStatusSubscription;
|
||||
|
||||
/// The current status of the Tor connection.
|
||||
TorConnectionStatus _torConnectionStatus = TorConnectionStatus.disconnected;
|
||||
late TorConnectionStatus _torConnectionStatus;
|
||||
|
||||
/// Builds the tor icon based on the current status.
|
||||
Widget _buildTorIcon(TorConnectionStatus status) {
|
||||
|
@ -176,6 +176,11 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
// Initialize the global event bus.
|
||||
eventBus = GlobalEventBus.instance;
|
||||
|
||||
// Initialize the TorConnectionStatus.
|
||||
_torConnectionStatus = TorService.sharedInstance.enabled
|
||||
? TorConnectionStatus.connected
|
||||
: TorConnectionStatus.disconnected;
|
||||
|
||||
// Subscribe to the TorConnectionStatusChangedEvent.
|
||||
_torConnectionStatusSubscription =
|
||||
eventBus.on<TorConnectionStatusChangedEvent>().listen(
|
||||
|
@ -271,7 +276,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
.watch(selectedSettingsMenuItemStateProvider.state)
|
||||
.state = 4;
|
||||
},
|
||||
child: _buildTorIcon(TorService.sharedInstance.status)),
|
||||
child: _buildTorIcon(_torConnectionStatus)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
|
|
|
@ -52,8 +52,10 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
|||
_torConnectionStatusSubscription;
|
||||
|
||||
/// The current status of the Tor connection.
|
||||
TorConnectionStatus _torConnectionStatus = TorConnectionStatus.disconnected;
|
||||
late TorConnectionStatus _torConnectionStatus =
|
||||
TorConnectionStatus.disconnected;
|
||||
|
||||
/// Build the connect/disconnect button.
|
||||
Widget _buildConnectButton(TorConnectionStatus status) {
|
||||
switch (status) {
|
||||
case TorConnectionStatus.disconnected:
|
||||
|
@ -99,6 +101,11 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
|||
// Initialize the global event bus.
|
||||
eventBus = GlobalEventBus.instance;
|
||||
|
||||
// Set the initial Tor connection status.
|
||||
_torConnectionStatus = TorService.sharedInstance.enabled
|
||||
? TorConnectionStatus.connected
|
||||
: TorConnectionStatus.disconnected;
|
||||
|
||||
// Subscribe to the TorConnectionStatusChangedEvent.
|
||||
_torConnectionStatusSubscription =
|
||||
eventBus.on<TorConnectionStatusChangedEvent>().listen(
|
||||
|
@ -259,7 +266,7 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
|||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: _buildConnectButton(TorService.sharedInstance.status),
|
||||
child: _buildConnectButton(_torConnectionStatus),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
|
|
|
@ -17,14 +17,6 @@ class TorService {
|
|||
/// Getter for the enabled flag.
|
||||
bool get enabled => _enabled;
|
||||
|
||||
/// The current status of the Tor connection.
|
||||
TorConnectionStatus _status = TorConnectionStatus.disconnected;
|
||||
|
||||
/// Getter for the status.
|
||||
///
|
||||
/// Used mostly to indicate "Connected" status in the UI.
|
||||
TorConnectionStatus get status => _status;
|
||||
|
||||
TorService._();
|
||||
|
||||
/// Singleton instance of the TorService.
|
||||
|
@ -49,9 +41,6 @@ class TorService {
|
|||
///
|
||||
/// Returns a Future that completes when the Tor service has started.
|
||||
Future<void> start() async {
|
||||
// Set the status to connecting.
|
||||
_status = TorConnectionStatus.connecting;
|
||||
|
||||
if (_enabled) {
|
||||
// already started so just return
|
||||
// could throw an exception here or something so the caller
|
||||
|
@ -74,9 +63,6 @@ class TorService {
|
|||
// has started successfully
|
||||
_enabled = true;
|
||||
|
||||
// Set the status to connected.
|
||||
_status = TorConnectionStatus.connected;
|
||||
|
||||
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
||||
GlobalEventBus.instance.fire(
|
||||
TorConnectionStatusChangedEvent(
|
||||
|
@ -91,9 +77,6 @@ class TorService {
|
|||
);
|
||||
// _enabled should already be false
|
||||
|
||||
// Set the status to disconnected.
|
||||
_status = TorConnectionStatus.disconnected;
|
||||
|
||||
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
||||
GlobalEventBus.instance.fire(
|
||||
TorConnectionStatusChangedEvent(
|
||||
|
@ -106,9 +89,6 @@ class TorService {
|
|||
}
|
||||
|
||||
Future<void> stop() async {
|
||||
// Set the status to disconnected.
|
||||
_status = TorConnectionStatus.disconnected;
|
||||
|
||||
if (!_enabled) {
|
||||
// already stopped so just return
|
||||
// could throw an exception here or something so the caller
|
||||
|
|
Loading…
Reference in a new issue