mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
c78662fbfe
* replace all print statements with printV * restore backup error message * missing print statements, error fixes * Update cw_core/lib/utils/print_verbose.dart [skip ci] * Update cw_core/lib/utils/print_verbose.dart [skip ci] * CW-846: Correctly display balance (#1848) * Correctly display balance even with frozen coins * remove package= from AndroidMainfest.xml * update namespace * print -> printV --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
38 lines
1.4 KiB
Dart
38 lines
1.4 KiB
Dart
import 'package:cake_wallet/entities/update_haven_rate.dart';
|
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/sync_status.dart';
|
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
|
|
ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
|
|
|
void startWalletSyncStatusChangeReaction(
|
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
|
|
FiatConversionStore fiatConversionStore) {
|
|
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
|
_onWalletSyncStatusChangeReaction = reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
|
try {
|
|
if (status is ConnectedSyncStatus) {
|
|
await wallet.startSync();
|
|
|
|
if (wallet.type == WalletType.haven) {
|
|
await updateHavenRate(fiatConversionStore);
|
|
}
|
|
}
|
|
if (status is SyncingSyncStatus) {
|
|
await WakelockPlus.enable();
|
|
}
|
|
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
|
await WakelockPlus.disable();
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
}
|