mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
* fix: Sync bar ETA * fix: Smooth ETA - WIP * fix: Show disconnected status when sync disconnects * feat: Display blocks remaining for the first five seconds and then switch to percentage * Update * fix: Extend duration for showing blocks remaining during sync from 5 to 15 seconds; update connectivity check to handle multiple connectivity results, and handle disconnected state while syncing * feat: Initially display block if the a reconnection is triggered while syncing * fix: More improvements to syncing
51 lines
1.7 KiB
Dart
51 lines
1.7 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/store/settings_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,
|
|
SettingsStore settingsStore) {
|
|
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
|
_onWalletSyncStatusChangeReaction = reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
|
try {
|
|
if (status is ConnectedSyncStatus) {
|
|
SyncingSyncStatus.resetSyncStartTime();
|
|
await wallet.startSync();
|
|
}
|
|
|
|
if (status is SyncingSyncStatus || status is ProcessingSyncStatus) {
|
|
await WakelockPlus.enable();
|
|
}
|
|
|
|
if (status is SyncedSyncStatus) {
|
|
await WakelockPlus.disable();
|
|
SyncingSyncStatus.resetSyncStartTime();
|
|
SyncingSyncStatus.blockHistory.clear();
|
|
}
|
|
|
|
if (status is FailedSyncStatus) {
|
|
await WakelockPlus.disable();
|
|
SyncingSyncStatus.resetSyncStartTime();
|
|
}
|
|
|
|
if (status is SyncedSyncStatus &&
|
|
wallet.type == WalletType.bitcoin &&
|
|
settingsStore.usePayjoin) {
|
|
bitcoin!.resumePayjoinSessions(wallet);
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
}
|