mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
fix currency filter
This commit is contained in:
parent
474ec39a5f
commit
d342dd5cb9
2 changed files with 8 additions and 14 deletions
|
@ -154,10 +154,6 @@ class _ExchangeCurrencySelectionViewState
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Currency>> _getCurrencies() async {
|
Future<List<Currency>> _getCurrencies() async {
|
||||||
// This is where exchanges are added to the list of available currencies.
|
|
||||||
//
|
|
||||||
// TODO: make an exchange's addition to the list of available currencies
|
|
||||||
// be dynamic and dependant upon the exchange's supportsTor implementation.
|
|
||||||
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
||||||
.where()
|
.where()
|
||||||
.filter()
|
.filter()
|
||||||
|
@ -178,12 +174,10 @@ class _ExchangeCurrencySelectionViewState
|
||||||
|
|
||||||
// If using Tor, filter exchanges which do not support Tor.
|
// If using Tor, filter exchanges which do not support Tor.
|
||||||
if (Prefs.instance.useTor) {
|
if (Prefs.instance.useTor) {
|
||||||
if (Exchange.exchangesWithTorSupport.isNotEmpty) {
|
if (Exchange.exchangeNamesWithTorSupport.isNotEmpty) {
|
||||||
currencies
|
currencies.removeWhere((element) => !Exchange
|
||||||
.removeWhere((element) => !Exchange.exchangesWithTorSupport.any(
|
.exchangeNamesWithTorSupport
|
||||||
(e) => e.name == element.exchangeName,
|
.contains(element.exchangeName));
|
||||||
));
|
|
||||||
// Could have also filtered using the List<String> Exchange.exchangeNamesWithTorSupport. But I didn't. This is fancier.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,8 @@ abstract class Exchange {
|
||||||
static List<String> get exchangeNamesWithTorSupport =>
|
static List<String> get exchangeNamesWithTorSupport =>
|
||||||
exchangesWithTorSupport.map((exchange) => exchange.name).toList();
|
exchangesWithTorSupport.map((exchange) => exchange.name).toList();
|
||||||
// Instead of using this, you can do like:
|
// Instead of using this, you can do like:
|
||||||
// currencies
|
// currencies.removeWhere((element) =>
|
||||||
// .removeWhere((element) => !Exchange.exchangesWithTorSupport.any(
|
// !Exchange.exchangesWithTorSupport.any((e) => e.name == element.exchangeName)
|
||||||
// (e) => e.name == element.exchangeName,
|
// );
|
||||||
// ));
|
// But this helper may be more readable.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue