11import 'package:bb_mobile/core/background_tasks/tasks.dart' ;
22import 'package:bb_mobile/core/storage/sqlite_database.dart' ;
3- import 'package:bb_mobile/core/swaps/domain/usecases/restart_swap_watcher_usecase .dart' ;
3+ import 'package:bb_mobile/core/swaps/domain/usecases/process_ongoing_swaps_usecase .dart' ;
44import 'package:bb_mobile/core/utils/logger.dart' show log;
55import 'package:bb_mobile/core/wallet/domain/usecases/get_wallets_usecase.dart' ;
66import 'package:bb_mobile/core/wallet/domain/usecases/sync_wallet_usecase.dart' ;
@@ -42,7 +42,7 @@ Future<bool> tasksHandler(String task) async {
4242
4343 final syncWalletUsecase = locator <SyncWalletUsecase >();
4444 final getWalletsUsecase = locator <GetWalletsUsecase >();
45- final restartSwapWatcherUsecase = locator <RestartSwapWatcherUsecase >();
45+ final processOngoingSwapsUsecase = locator <ProcessOngoingSwapsUsecase >();
4646
4747 final backgroundTask = BackgroundTask .fromName (task);
4848
@@ -64,7 +64,14 @@ Future<bool> tasksHandler(String task) async {
6464 if (wallets.isEmpty) {
6565 log.warning ('No wallets to sync' );
6666 } else {
67- await restartSwapWatcherUsecase.execute ();
67+ // Poll + act to completion: the BG isolate dies right after this
68+ // returns, so a websocket-based restart would never see an event.
69+ // Bounded to respect the iOS background budget.
70+ await processOngoingSwapsUsecase.execute ().timeout (
71+ const Duration (seconds: 25 ),
72+ onTimeout: () =>
73+ log.warning ('Swaps background processing hit time budget' ),
74+ );
6875 }
6976 case BackgroundTask .logsPrune:
7077 await log.prune ();
0 commit comments