warning fix pt.2

This commit is contained in:
Matthew Fosse 2024-03-07 08:24:15 -08:00
parent f4465db453
commit e1a76949dd
3 changed files with 104 additions and 73 deletions

View file

@ -44,7 +44,8 @@ class MainActions {
return;
}
if (viewModel.isTorEnabled) {
if (viewModel.isTorEnabled && viewModel.settingsStore.shouldShowTorBuyWarning) {
viewModel.settingsStore.shouldShowTorBuyWarning = false;
await _showErrorDialog(context, S.of(context).warning, S.of(context).tor_enabled_warning);
}
@ -104,7 +105,8 @@ class MainActions {
return;
}
if (viewModel.isTorEnabled) {
if (viewModel.isTorEnabled && viewModel.settingsStore.shouldShowTorSellWarning) {
viewModel.settingsStore.shouldShowTorSellWarning = false;
await _showErrorDialog(context, S.of(context).warning, S.of(context).tor_enabled_warning);
}

View file

@ -61,8 +61,8 @@ class PreferencesKey {
static const lookupsUnstoppableDomains = 'looks_up_mastodon';
static const lookupsOpenAlias = 'looks_up_mastodon';
static const lookupsENS = 'looks_up_ens';
static const shownTorSellWarning = 'shown_tor_sell_warning';
static const shownTorBuyWarning = 'shown_tor_buy_warning';
static const shouldShowTorSellWarning = 'shown_tor_sell_warning';
static const shouldShowTorBuyWarning = 'shown_tor_buy_warning';
static String moneroWalletUpdateV1Key(String name) =>

View file

@ -80,6 +80,8 @@ abstract class SettingsStoreBase with Store {
required Map<WalletType, Node> nodes,
required Map<WalletType, Node> powNodes,
required this.shouldShowYatPopup,
required this.shouldShowTorBuyWarning,
required this.shouldShowTorSellWarning,
required this.isBitcoinBuyEnabled,
required this.actionlistDisplayMode,
required this.pinTimeOutDuration,
@ -225,6 +227,16 @@ abstract class SettingsStoreBase with Store {
(bool shouldShowYatPopup) =>
sharedPreferences.setBool(PreferencesKey.shouldShowYatPopup, shouldShowYatPopup));
reaction(
(_) => shouldShowTorBuyWarning,
(bool shouldShowTorBuyWarning) => sharedPreferences.setBool(
PreferencesKey.shouldShowTorBuyWarning, shouldShowTorBuyWarning));
reaction(
(_) => shouldShowTorSellWarning,
(bool shouldShowTorSellWarning) => sharedPreferences.setBool(
PreferencesKey.shouldShowTorSellWarning, shouldShowTorSellWarning));
defaultBuyProviders.observe((change) {
final String key = 'buyProvider_${change.key.toString()}';
if (change.newValue != null) {
@ -530,6 +542,12 @@ abstract class SettingsStoreBase with Store {
@observable
bool shouldShowYatPopup;
@observable
bool shouldShowTorBuyWarning;
@observable
bool shouldShowTorSellWarning;
@observable
bool shouldShowMarketPlaceInDashboard;
@ -870,6 +888,10 @@ abstract class SettingsStoreBase with Store {
final packageInfo = await PackageInfo.fromPlatform();
final deviceName = await _getDeviceName() ?? '';
final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
final shouldShowTorBuyWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorBuyWarning) ?? true;
final shouldShowTorSellWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorSellWarning) ?? true;
final generateSubaddresses =
sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey);
@ -1093,7 +1115,10 @@ abstract class SettingsStoreBase with Store {
backgroundTasks: backgroundTasks,
initialSyncMode: savedSyncMode,
initialSyncAll: savedSyncAll,
shouldShowYatPopup: shouldShowYatPopup);
shouldShowYatPopup: shouldShowYatPopup,
shouldShowTorBuyWarning: shouldShowTorBuyWarning,
shouldShowTorSellWarning: shouldShowTorSellWarning,
);
}
Future<void> reload({required Box<Node> nodeSource}) async {
@ -1187,6 +1212,10 @@ abstract class SettingsStoreBase with Store {
languageCode = sharedPreferences.getString(PreferencesKey.currentLanguageCode) ?? languageCode;
shouldShowYatPopup =
sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? shouldShowYatPopup;
shouldShowTorBuyWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorBuyWarning) ?? shouldShowTorBuyWarning;
shouldShowTorSellWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorSellWarning) ?? shouldShowTorSellWarning;
sortBalanceBy = SortBalanceBy
.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index];
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;