disable exchange data loading based on enableExchange pref

and refactor showExchange->enableExchange
This commit is contained in:
sneurlax 2024-07-02 22:52:51 -05:00
parent 2b2127aeb5
commit 220cf65520
9 changed files with 18 additions and 17 deletions

View file

@ -378,7 +378,8 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
// TODO: this should probably run unawaited. Keep commented out for now as proper community nodes ui hasn't been implemented yet
// unawaited(_nodeService.updateCommunityNodes());
if (AppConfig.hasFeature(AppFeature.swap)) {
if (AppConfig.hasFeature(AppFeature.swap) &&
ref.read(prefsChangeNotifierProvider).enableExchange) {
await ExchangeDataLoadingService.instance.initDB();
// run without awaiting
if (ref.read(prefsChangeNotifierProvider).externalCalls &&

View file

@ -46,7 +46,7 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
Widget build(BuildContext context) {
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showExchange = prefs.enableExchange;
final selectedIndex = ref.watch(homeViewPageIndexStateProvider.state).state;
return Row(

View file

@ -204,7 +204,7 @@ class AdvancedSettingsView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Show exchange features",
"Enable exchange features",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
@ -214,13 +214,13 @@ class AdvancedSettingsView extends StatelessWidget {
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.showExchange,
(value) => value.enableExchange,
),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.showExchange = newValue;
.enableExchange = newValue;
},
),
),

View file

@ -219,7 +219,7 @@ class TokenWalletOptions extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showExchange = prefs.enableExchange;
return Row(
mainAxisAlignment: MainAxisAlignment.center,

View file

@ -519,7 +519,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
final coin = ref.watch(pWalletCoin(walletId));
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showExchange = prefs.enableExchange;
return ConditionalParent(
condition: _rescanningOnOpen,

View file

@ -117,7 +117,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
Widget build(BuildContext context) {
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showExchange = prefs.enableExchange;
return Material(
color: Theme.of(context).extension<StackColors>()!.popupBG,

View file

@ -354,7 +354,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
final coin = wallet.info.coin;
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showExchange = prefs.enableExchange;
final showMore = wallet is PaynymInterface ||
(wallet is CoinControlInterface &&

View file

@ -174,7 +174,7 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Show exchange features",
"Enable exchange features",
style: STextStyles.desktopTextExtraSmall(context)
.copyWith(
color: Theme.of(context)
@ -189,13 +189,13 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.showExchange,
(value) => value.enableExchange,
),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.showExchange = newValue;
.enableExchange = newValue;
},
),
),

View file

@ -1133,18 +1133,18 @@ class Prefs extends ChangeNotifier {
// Show or hide exchange (buy & swap) features.
bool _showExchange = true;
bool _enableExchange = true;
bool get showExchange => _showExchange;
bool get enableExchange => _enableExchange;
set showExchange(bool showExchange) {
if (_showExchange != showExchange) {
set enableExchange(bool showExchange) {
if (_enableExchange != showExchange) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "showExchange",
value: showExchange,
);
_showExchange = showExchange;
_enableExchange = showExchange;
notifyListeners();
}
}