mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
add tor status change event and fire on pref changed
This commit is contained in:
parent
7dabba3d0e
commit
6e625e2c74
2 changed files with 40 additions and 2 deletions
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is part of Stack Wallet.
|
||||
*
|
||||
* Copyright (c) 2023 Cypher Stack
|
||||
* All Rights Reserved.
|
||||
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
||||
* Generated by Cypher Stack on 2023-05-26
|
||||
*
|
||||
*/
|
||||
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
||||
enum TorStatus { enabled, disabled }
|
||||
|
||||
class TorStatusChangedEvent {
|
||||
String? message;
|
||||
TorStatus status;
|
||||
|
||||
TorStatusChangedEvent({
|
||||
required this.status,
|
||||
this.message,
|
||||
}) {
|
||||
Logging.instance.log(
|
||||
"TorStatusChangedEvent changed to \"$status\" with message: $message",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_unit.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||
|
@ -886,12 +888,20 @@ class Prefs extends ChangeNotifier {
|
|||
);
|
||||
_useTor = useTor;
|
||||
notifyListeners();
|
||||
GlobalEventBus.instance.fire(
|
||||
TorStatusChangedEvent(
|
||||
status: useTor ? TorStatus.enabled : TorStatus.disabled,
|
||||
message: "useTor updated in prefs",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _getUseTor() async {
|
||||
return await DB.instance
|
||||
.get<dynamic>(boxName: DB.boxNamePrefs, key: "useTor") as bool? ??
|
||||
return await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "useTor",
|
||||
) as bool? ??
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue