mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Fixes for gray screen bug.
This commit is contained in:
parent
606f4e59c5
commit
2eb229b91e
5 changed files with 36 additions and 7 deletions
|
@ -175,6 +175,7 @@ extern "C"
|
||||||
Monero::SubaddressAccount *m_account;
|
Monero::SubaddressAccount *m_account;
|
||||||
uint64_t m_last_known_wallet_height;
|
uint64_t m_last_known_wallet_height;
|
||||||
uint64_t m_cached_syncing_blockchain_height = 0;
|
uint64_t m_cached_syncing_blockchain_height = 0;
|
||||||
|
std::mutex store_mutex;
|
||||||
|
|
||||||
|
|
||||||
void change_current_wallet(Monero::Wallet *wallet)
|
void change_current_wallet(Monero::Wallet *wallet)
|
||||||
|
@ -293,6 +294,7 @@ extern "C"
|
||||||
|
|
||||||
void load_wallet(char *path, char *password, int32_t nettype)
|
void load_wallet(char *path, char *password, int32_t nettype)
|
||||||
{
|
{
|
||||||
|
nice(19);
|
||||||
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
|
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
|
||||||
Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->openWallet(std::string(path), std::string(password), networkType);
|
Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->openWallet(std::string(path), std::string(password), networkType);
|
||||||
change_current_wallet(wallet);
|
change_current_wallet(wallet);
|
||||||
|
@ -429,7 +431,9 @@ extern "C"
|
||||||
|
|
||||||
void store(char *path)
|
void store(char *path)
|
||||||
{
|
{
|
||||||
|
store_mutex.lock();
|
||||||
get_current_wallet()->store(std::string(path));
|
get_current_wallet()->store(std::string(path));
|
||||||
|
store_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool transaction_create(char *address, char *payment_id, char *amount,
|
bool transaction_create(char *address, char *payment_id, char *amount,
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
4dc2ef1ba73deeed13cd85894dacb10b
|
|
23
lib/di.dart
23
lib/di.dart
|
@ -61,6 +61,7 @@ import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
|
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
|
||||||
|
@ -177,11 +178,25 @@ Future setup(
|
||||||
BiometricAuth()));
|
BiometricAuth()));
|
||||||
|
|
||||||
getIt.registerFactory<AuthPage>(
|
getIt.registerFactory<AuthPage>(
|
||||||
() => AuthPage(getIt.get<AuthViewModel>(),
|
() => AuthPage(getIt.get<AuthViewModel>(), onAuthenticationFinished:
|
||||||
onAuthenticationFinished: (isAuthenticated, __) {
|
(isAuthenticated, AuthPageState authPageState) {
|
||||||
if (isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
getIt.get<AuthenticationStore>().allowed();
|
return;
|
||||||
}
|
}
|
||||||
|
final authStore = getIt.get<AuthenticationStore>();
|
||||||
|
final appStore = getIt.get<AppStore>();
|
||||||
|
|
||||||
|
if (appStore.wallet != null) {
|
||||||
|
authStore.allowed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
authPageState.changeProcessText('Loading the wallet');
|
||||||
|
ReactionDisposer _reaction;
|
||||||
|
_reaction = reaction((_) => appStore.wallet, (Object _) {
|
||||||
|
_reaction?.reaction?.dispose();
|
||||||
|
authStore.allowed();
|
||||||
|
});
|
||||||
}, closable: false),
|
}, closable: false),
|
||||||
instanceName: 'login');
|
instanceName: 'login');
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import 'package:cake_wallet/entities/wallet_info.dart';
|
||||||
import 'package:cake_wallet/entities/node.dart';
|
import 'package:cake_wallet/entities/node.dart';
|
||||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||||
|
|
||||||
|
|
||||||
part 'monero_wallet.g.dart';
|
part 'monero_wallet.g.dart';
|
||||||
|
|
||||||
const moneroBlockSize = 1000;
|
const moneroBlockSize = 1000;
|
||||||
|
@ -40,6 +41,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
subaddress = subaddressList.subaddresses.first;
|
subaddress = subaddressList.subaddresses.first;
|
||||||
address = subaddress.address;
|
address = subaddress.address;
|
||||||
});
|
});
|
||||||
|
_cachedRefreshHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -80,6 +82,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
String _filename;
|
String _filename;
|
||||||
SyncListner _listener;
|
SyncListner _listener;
|
||||||
ReactionDisposer _onAccountChangeReaction;
|
ReactionDisposer _onAccountChangeReaction;
|
||||||
|
int _cachedRefreshHeight;
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
await accountList.update();
|
await accountList.update();
|
||||||
|
@ -177,7 +180,9 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> save() async {
|
Future<void> save() async {
|
||||||
|
print('SAVE CALLED');
|
||||||
await monero_wallet.store();
|
await monero_wallet.store();
|
||||||
|
print('SAVE FINISHED');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getNodeHeight() async => monero_wallet.getNodeHeight();
|
Future<int> getNodeHeight() async => monero_wallet.getNodeHeight();
|
||||||
|
@ -191,12 +196,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> rescan({int height}) async {
|
Future<void> rescan({int height}) async {
|
||||||
|
walletInfo.restoreHeight = height;
|
||||||
|
walletInfo.isRecovery = true;
|
||||||
monero_wallet.setRefreshFromBlockHeight(height: height);
|
monero_wallet.setRefreshFromBlockHeight(height: height);
|
||||||
monero_wallet.rescanBlockchainAsync();
|
monero_wallet.rescanBlockchainAsync();
|
||||||
await startSync();
|
await startSync();
|
||||||
_askForUpdateBalance();
|
_askForUpdateBalance();
|
||||||
await _askForUpdateTransactionHistory();
|
await _askForUpdateTransactionHistory();
|
||||||
await save();
|
await save();
|
||||||
|
await walletInfo.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setListeners() {
|
void _setListeners() {
|
||||||
|
@ -284,8 +292,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
await setAsRecovered();
|
await setAsRecovered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentHeight - _cachedRefreshHeight > moneroBlockSize) {
|
||||||
|
_cachedRefreshHeight = currentHeight;
|
||||||
await save();
|
await save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _onNewTransaction() {
|
void _onNewTransaction() {
|
||||||
_askForUpdateBalance();
|
_askForUpdateBalance();
|
||||||
|
|
|
@ -87,8 +87,8 @@ class WalletMenu {
|
||||||
rightButtonText: S.of(context).ok,
|
rightButtonText: S.of(context).ok,
|
||||||
leftButtonText: S.of(context).cancel,
|
leftButtonText: S.of(context).cancel,
|
||||||
actionRightButton: () async {
|
actionRightButton: () async {
|
||||||
await reconnect?.call();
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
await reconnect?.call();
|
||||||
},
|
},
|
||||||
actionLeftButton: () => Navigator.of(context).pop());
|
actionLeftButton: () => Navigator.of(context).pop());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue