Skip to content

Commit

Permalink
Potential fix for the race condition of loading a wallet while the na…
Browse files Browse the repository at this point in the history
…me in the shared prefs hasn't updated yet (#1801)
  • Loading branch information
OmarHatem28 authored Nov 13, 2024
1 parent 0adb69d commit ed5e701
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/reactions/on_current_wallet_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:mobx/mobx.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/reactions/check_connection.dart';
import 'package:cake_wallet/reactions/on_wallet_sync_status_change.dart';
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
Expand Down Expand Up @@ -65,10 +62,6 @@ void startCurrentWalletChangeReaction(

startWalletSyncStatusChangeReaction(wallet, fiatConversionStore);
startCheckConnectionReaction(wallet, settingsStore);
await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
await getIt
.get<SharedPreferences>()
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));

if (wallet.type == WalletType.monero ||
wallet.type == WalletType.wownero ||
Expand Down
7 changes: 7 additions & 0 deletions lib/store/app_store.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:cake_wallet/core/wallet_connect/web3wallet_service.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/wallet_base.dart';
Expand All @@ -11,6 +13,7 @@ import 'package:cake_wallet/store/wallet_list_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/node_list_store.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'app_store.g.dart';

Expand Down Expand Up @@ -47,5 +50,9 @@ abstract class AppStoreBase with Store {
getIt.get<Web3WalletService>().create();
await getIt.get<Web3WalletService>().init();
}
await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
await getIt
.get<SharedPreferences>()
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
}
}

0 comments on commit ed5e701

Please sign in to comment.