Show staged sync status after wallet open
build / Build Linux wallet (push) Successful in 2m25s
build / Build Windows wallet (push) Has started running

This commit is contained in:
Codex Bot
2026-04-20 01:29:19 +02:00
parent aa5d4542b7
commit 0b13cf6f46
3 changed files with 37 additions and 7 deletions
+4 -3
View File
@@ -94,8 +94,7 @@ class _PeyaAppState extends ConsumerState<PeyaApp> with WindowListener {
if (messenger == null) {
return;
}
final shouldShowStatus = next.isLoading &&
!next.isBlockingOperation &&
final shouldShowStatus = !next.isBlockingOperation &&
next.operationMessage != null &&
next.operationMessage!.isNotEmpty;
@@ -274,7 +273,9 @@ class _PeyaAppState extends ConsumerState<PeyaApp> with WindowListener {
await ref
.read(walletControllerProvider.notifier)
.connectNode(config.nodeConfig);
await ref.read(walletControllerProvider.notifier).syncNow();
await ref
.read(walletControllerProvider.notifier)
.syncNow(announceStages: true);
final syncedState = ref.read(walletControllerProvider);
if (syncedState.syncStatus.lastSync != null) {
return true;
+30 -3
View File
@@ -133,12 +133,15 @@ class WalletController extends StateNotifier<WalletState> {
required String password,
}) async {
await _runWithLoading(() async {
_updateOperationStatus('Preparing wallet directory...');
await Directory(path).create(recursive: true);
final resolvedPath = _resolveWalletFilePath(path, name: name);
_updateOperationStatus('Creating wallet...');
await _cacheRecovery.markOpenAttempt(resolvedPath);
await _repository.createWallet(
name: name, path: path, password: password);
try {
_updateOperationStatus('Loading wallet data...');
await _postOpen(name: name, path: resolvedPath);
} finally {
await _cacheRecovery.clearOpenAttempt();
@@ -151,8 +154,10 @@ class WalletController extends StateNotifier<WalletState> {
required String password,
}) async {
return _runWithLoading(() async {
_updateOperationStatus('Preparing temporary wallet...');
final tempDir = await Directory.systemTemp.createTemp('peyawallet-draft-');
try {
_updateOperationStatus('Generating seed phrase...');
await _repository.createWallet(
name: name,
path: tempDir.path,
@@ -179,8 +184,10 @@ class WalletController extends StateNotifier<WalletState> {
required String password,
}) async {
await _runWithLoading(() async {
_updateOperationStatus('Preparing wallet directory...');
await Directory(path).create(recursive: true);
final resolvedPath = _resolveWalletFilePath(path, name: name);
_updateOperationStatus('Restoring wallet from seed...');
await _cacheRecovery.markOpenAttempt(resolvedPath);
await _repository.restoreWalletFromSeed(
name: name,
@@ -189,6 +196,7 @@ class WalletController extends StateNotifier<WalletState> {
password: password,
);
try {
_updateOperationStatus('Loading wallet data...');
await _postOpen(name: name, path: resolvedPath);
} finally {
await _cacheRecovery.clearOpenAttempt();
@@ -202,10 +210,13 @@ class WalletController extends StateNotifier<WalletState> {
}) async {
await _runWithLoading(() async {
final resolvedPath = _resolveOpenPath(path);
_updateOperationStatus('Checking wallet files...');
await _cacheRecovery.recoverIfNeeded(resolvedPath);
_updateOperationStatus('Opening wallet...');
await _cacheRecovery.markOpenAttempt(resolvedPath);
try {
await _repository.openWallet(path: resolvedPath, password: password);
_updateOperationStatus('Loading wallet data...');
await _postOpen(name: p.basename(resolvedPath), path: resolvedPath);
} finally {
await _cacheRecovery.clearOpenAttempt();
@@ -353,18 +364,21 @@ class WalletController extends StateNotifier<WalletState> {
await _repository.discardPreparedStake();
}
Future<void> syncNow() async {
Future<void> syncNow({bool announceStages = false}) async {
if (state.isSyncing || state.walletInfo == null) {
return;
}
state = state.copyWith(isSyncing: true);
try {
await _ensureConnected();
await _refreshSnapshot();
await _refreshSnapshot(announceStages: announceStages);
} catch (error, stack) {
_logger.e('Sync failed', error: error, stackTrace: stack);
state = state.copyWith(error: error.toString());
} finally {
if (announceStages) {
_updateOperationStatus(null);
}
state = state.copyWith(isSyncing: false);
}
}
@@ -411,8 +425,14 @@ class WalletController extends StateNotifier<WalletState> {
);
}
Future<WalletSnapshot> _refreshSnapshot() async {
Future<WalletSnapshot> _refreshSnapshot({bool announceStages = false}) async {
if (announceStages) {
_updateOperationStatus('Refreshing balances...');
}
final snapshot = await _repository.refresh();
if (announceStages) {
_updateOperationStatus('Loading transactions...');
}
final transactions = await _repository.getTransactions();
final syncStatus = SyncStatus(
synced: snapshot.synced,
@@ -464,6 +484,13 @@ class WalletController extends StateNotifier<WalletState> {
}
}
void _updateOperationStatus(String? message) {
state = state.copyWith(
operationMessage: message,
isBlockingOperation: false,
);
}
String _resolveWalletFilePath(String basePath, {required String name}) {
if (basePath.isEmpty) {
return basePath;
+3 -1
View File
@@ -449,7 +449,9 @@ class _LocalNodeControlsState extends ConsumerState<_LocalNodeControls> {
for (var attempt = 0; attempt < 10; attempt++) {
try {
await ref.read(walletControllerProvider.notifier).connectNode(nodeConfig);
await ref.read(walletControllerProvider.notifier).syncNow();
await ref
.read(walletControllerProvider.notifier)
.syncNow(announceStages: true);
final state = ref.read(walletControllerProvider);
if (state.syncStatus.lastSync != null) {
break;