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; 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); await _showErrorDialog(context, S.of(context).warning, S.of(context).tor_enabled_warning);
} }
@ -104,7 +105,8 @@ class MainActions {
return; 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); 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 lookupsUnstoppableDomains = 'looks_up_mastodon';
static const lookupsOpenAlias = 'looks_up_mastodon'; static const lookupsOpenAlias = 'looks_up_mastodon';
static const lookupsENS = 'looks_up_ens'; static const lookupsENS = 'looks_up_ens';
static const shownTorSellWarning = 'shown_tor_sell_warning'; static const shouldShowTorSellWarning = 'shown_tor_sell_warning';
static const shownTorBuyWarning = 'shown_tor_buy_warning'; static const shouldShowTorBuyWarning = 'shown_tor_buy_warning';
static String moneroWalletUpdateV1Key(String name) => 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> nodes,
required Map<WalletType, Node> powNodes, required Map<WalletType, Node> powNodes,
required this.shouldShowYatPopup, required this.shouldShowYatPopup,
required this.shouldShowTorBuyWarning,
required this.shouldShowTorSellWarning,
required this.isBitcoinBuyEnabled, required this.isBitcoinBuyEnabled,
required this.actionlistDisplayMode, required this.actionlistDisplayMode,
required this.pinTimeOutDuration, required this.pinTimeOutDuration,
@ -225,6 +227,16 @@ abstract class SettingsStoreBase with Store {
(bool shouldShowYatPopup) => (bool shouldShowYatPopup) =>
sharedPreferences.setBool(PreferencesKey.shouldShowYatPopup, 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) { defaultBuyProviders.observe((change) {
final String key = 'buyProvider_${change.key.toString()}'; final String key = 'buyProvider_${change.key.toString()}';
if (change.newValue != null) { if (change.newValue != null) {
@ -530,6 +542,12 @@ abstract class SettingsStoreBase with Store {
@observable @observable
bool shouldShowYatPopup; bool shouldShowYatPopup;
@observable
bool shouldShowTorBuyWarning;
@observable
bool shouldShowTorSellWarning;
@observable @observable
bool shouldShowMarketPlaceInDashboard; bool shouldShowMarketPlaceInDashboard;
@ -870,6 +888,10 @@ abstract class SettingsStoreBase with Store {
final packageInfo = await PackageInfo.fromPlatform(); final packageInfo = await PackageInfo.fromPlatform();
final deviceName = await _getDeviceName() ?? ''; final deviceName = await _getDeviceName() ?? '';
final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true; final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
final shouldShowTorBuyWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorBuyWarning) ?? true;
final shouldShowTorSellWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorSellWarning) ?? true;
final generateSubaddresses = final generateSubaddresses =
sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey); sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey);
@ -1093,7 +1115,10 @@ abstract class SettingsStoreBase with Store {
backgroundTasks: backgroundTasks, backgroundTasks: backgroundTasks,
initialSyncMode: savedSyncMode, initialSyncMode: savedSyncMode,
initialSyncAll: savedSyncAll, initialSyncAll: savedSyncAll,
shouldShowYatPopup: shouldShowYatPopup); shouldShowYatPopup: shouldShowYatPopup,
shouldShowTorBuyWarning: shouldShowTorBuyWarning,
shouldShowTorSellWarning: shouldShowTorSellWarning,
);
} }
Future<void> reload({required Box<Node> nodeSource}) async { Future<void> reload({required Box<Node> nodeSource}) async {
@ -1187,6 +1212,10 @@ abstract class SettingsStoreBase with Store {
languageCode = sharedPreferences.getString(PreferencesKey.currentLanguageCode) ?? languageCode; languageCode = sharedPreferences.getString(PreferencesKey.currentLanguageCode) ?? languageCode;
shouldShowYatPopup = shouldShowYatPopup =
sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? shouldShowYatPopup; sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? shouldShowYatPopup;
shouldShowTorBuyWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorBuyWarning) ?? shouldShowTorBuyWarning;
shouldShowTorSellWarning =
sharedPreferences.getBool(PreferencesKey.shouldShowTorSellWarning) ?? shouldShowTorSellWarning;
sortBalanceBy = SortBalanceBy sortBalanceBy = SortBalanceBy
.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index]; .values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index];
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true; pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;