From 89778e6e6352d46d77984a08430719220375d9db Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 14 Jan 2023 11:22:48 -0600 Subject: [PATCH] disable BuyDataLoadingService --- lib/main.dart | 6 +- lib/pages/buy_view/buy_form.dart | 9 +- lib/pages/home_view/home_view.dart | 27 ++-- .../sub_widgets/home_view_button_bar.dart | 3 +- lib/pages/stack_privacy_calls.dart | 5 +- lib/pages_desktop_specific/desktop_menu.dart | 3 +- .../buy/buy_data_loading_service.dart | 124 +++++++++--------- 7 files changed, 86 insertions(+), 91 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 575aed02d..432f6be24 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -293,9 +293,9 @@ class _MaterialAppWithThemeState extends ConsumerState if (Constants.enableExchange) { unawaited(ExchangeDataLoadingService().loadAll(ref)); } - if (Constants.enableBuy) { - unawaited(BuyDataLoadingService().loadAll(ref)); - } + // if (Constants.enableBuy) { + // unawaited(BuyDataLoadingService().loadAll(ref)); + // } } if (ref.read(prefsChangeNotifierProvider).isAutoBackupEnabled) { diff --git a/lib/pages/buy_view/buy_form.dart b/lib/pages/buy_view/buy_form.dart index 44b6ef7ab..2c626c64b 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -7,7 +7,6 @@ import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dar import 'package:stackwallet/pages/buy_view/sub_widgets/fiat_crypto_toggle.dart'; import 'package:stackwallet/pages/buy_view/sub_widgets/fiat_selection_view.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; @@ -247,10 +246,10 @@ class _BuyFormState extends ConsumerState { coins = ref.read(supportedSimplexCurrenciesProvider).supportedCryptos; fiats = ref.read(supportedSimplexCurrenciesProvider).supportedFiats; - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - BuyDataLoadingService().loadAll( - ref); // Why does this need to be called here? Shouldn't it already be called by main.dart? - }); + // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + // BuyDataLoadingService().loadAll( + // ref); // Why does this need to be called here? Shouldn't it already be called by main.dart? + // }); // TODO set initial crypto to open wallet if a wallet is open diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index f1629c2a3..c11485271 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -15,7 +15,6 @@ import 'package:stackwallet/providers/global/notifications_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/ui/home_view_index_provider.dart'; import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -47,7 +46,7 @@ class _HomeViewState extends ConsumerState { bool _exitEnabled = false; final _exchangeDataLoadingService = ExchangeDataLoadingService(); - final _buyDataLoadingService = BuyDataLoadingService(); + // final _buyDataLoadingService = BuyDataLoadingService(); Future _onWillPop() async { // go to home view when tapping back on the main exchange view @@ -95,15 +94,15 @@ class _HomeViewState extends ConsumerState { } } - void _loadSimplexData() { - // unawaited future - if (ref.read(prefsChangeNotifierProvider).externalCalls) { - _buyDataLoadingService.loadAll(ref); - } else { - Logging.instance.log("User does not want to use external calls", - level: LogLevel.Info); - } - } + // void _loadSimplexData() { + // // unawaited future + // if (ref.read(prefsChangeNotifierProvider).externalCalls) { + // _buyDataLoadingService.loadAll(ref); + // } else { + // Logging.instance.log("User does not want to use external calls", + // level: LogLevel.Info); + // } + // } @override void initState() { @@ -320,9 +319,9 @@ class _HomeViewState extends ConsumerState { if (next == 1) { _exchangeDataLoadingService.loadAll(ref); } - if (next == 2) { - _buyDataLoadingService.loadAll(ref); - } + // if (next == 2) { + // _buyDataLoadingService.loadAll(ref); + // } if (next >= 0 && next <= 2) { _pageController.animateToPage( next, diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index e02d02ec0..80dee58c4 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -149,7 +148,7 @@ class _HomeViewButtonBarState extends ConsumerState { if (selectedIndex != 2) { ref.read(homeViewPageIndexStateProvider.state).state = 2; } - await BuyDataLoadingService().loadAll(ref); + // await BuyDataLoadingService().loadAll(ref); }, child: Text( "Buy", diff --git a/lib/pages/stack_privacy_calls.dart b/lib/pages/stack_privacy_calls.dart index 2ff954835..e120d238b 100644 --- a/lib/pages/stack_privacy_calls.dart +++ b/lib/pages/stack_privacy_calls.dart @@ -8,7 +8,6 @@ import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -233,8 +232,8 @@ class _StackPrivacyCalls extends ConsumerState { if (isEasy) { unawaited(ExchangeDataLoadingService() .loadAll(ref)); - unawaited( - BuyDataLoadingService().loadAll(ref)); + // unawaited( + // BuyDataLoadingService().loadAll(ref)); ref .read(priceAnd24hChangeNotifierProvider) .start(true); diff --git a/lib/pages_desktop_specific/desktop_menu.dart b/lib/pages_desktop_specific/desktop_menu.dart index 12058e635..b705a33be 100644 --- a/lib/pages_desktop_specific/desktop_menu.dart +++ b/lib/pages_desktop_specific/desktop_menu.dart @@ -4,7 +4,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart'; import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -44,7 +43,7 @@ class _DesktopMenuState extends ConsumerState { double _width = expandedWidth; - final _buyDataLoadingService = BuyDataLoadingService(); + // final _buyDataLoadingService = BuyDataLoadingService(); void updateSelectedMenuItem(DesktopMenuItemId idKey) { widget.onSelectionWillChange?.call(idKey); diff --git a/lib/services/buy/buy_data_loading_service.dart b/lib/services/buy/buy_data_loading_service.dart index 35b5e4e1c..93999c221 100644 --- a/lib/services/buy/buy_data_loading_service.dart +++ b/lib/services/buy/buy_data_loading_service.dart @@ -1,62 +1,62 @@ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/buy/simplex/simplex_api.dart'; -import 'package:stackwallet/utilities/logger.dart'; - -class BuyDataLoadingService { - Future loadAll(WidgetRef ref) async { - try { - await Future.wait([ - _loadSimplexCurrencies(ref), - ]); - } catch (e, s) { - Logging.instance.log("BuyDataLoadingService.loadAll failed: $e\n$s", - level: LogLevel.Error); - } - } - - Future _loadSimplexCurrencies(WidgetRef ref) async { - bool error = false; - // if (ref.read(simplexLoadStatusStateProvider.state).state == - // SimplexLoadStatus.loading) { - // // already in progress so just - // return; - // } - - ref.read(simplexLoadStatusStateProvider.state).state = - SimplexLoadStatus.loading; - - final response = await SimplexAPI.instance.getSupported(); - - if (response.value != null) { - ref - .read(supportedSimplexCurrenciesProvider) - .updateSupportedCryptos(response.value!.item1); - } else { - error = true; - Logging.instance.log( - "_loadSimplexCurrencies: $response", - level: LogLevel.Warning, - ); - } - - if (response.value != null) { - ref - .read(supportedSimplexCurrenciesProvider) - .updateSupportedFiats(response.value!.item2); - } else { - error = true; - Logging.instance.log( - "_loadSimplexCurrencies: $response", - level: LogLevel.Warning, - ); - } - - if (error) { - // _loadSimplexCurrencies() again? - } else { - ref.read(simplexLoadStatusStateProvider.state).state = - SimplexLoadStatus.success; - } - } -} +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:stackwallet/providers/providers.dart'; +// import 'package:stackwallet/services/buy/simplex/simplex_api.dart'; +// import 'package:stackwallet/utilities/logger.dart'; +// +// class BuyDataLoadingService { +// Future loadAll(WidgetRef ref) async { +// try { +// await Future.wait([ +// _loadSimplexCurrencies(ref), +// ]); +// } catch (e, s) { +// Logging.instance.log("BuyDataLoadingService.loadAll failed: $e\n$s", +// level: LogLevel.Error); +// } +// } +// +// Future _loadSimplexCurrencies(WidgetRef ref) async { +// bool error = false; +// // if (ref.read(simplexLoadStatusStateProvider.state).state == +// // SimplexLoadStatus.loading) { +// // // already in progress so just +// // return; +// // } +// +// ref.read(simplexLoadStatusStateProvider.state).state = +// SimplexLoadStatus.loading; +// +// final response = await SimplexAPI.instance.getSupported(); +// +// if (response.value != null) { +// ref +// .read(supportedSimplexCurrenciesProvider) +// .updateSupportedCryptos(response.value!.item1); +// } else { +// error = true; +// Logging.instance.log( +// "_loadSimplexCurrencies: $response", +// level: LogLevel.Warning, +// ); +// } +// +// if (response.value != null) { +// ref +// .read(supportedSimplexCurrenciesProvider) +// .updateSupportedFiats(response.value!.item2); +// } else { +// error = true; +// Logging.instance.log( +// "_loadSimplexCurrencies: $response", +// level: LogLevel.Warning, +// ); +// } +// +// if (error) { +// // _loadSimplexCurrencies() again? +// } else { +// ref.read(simplexLoadStatusStateProvider.state).state = +// SimplexLoadStatus.success; +// } +// } +// }