diff --git a/lib/data/models/transaction_cubit_remove.dart b/lib/data/models/transaction_cubit_remove.dart index bb0cc995d9fed6db162578cda7588365f6a29ecf..548215cfff29980412cd974095df6fbbd2525bc9 100644 --- a/lib/data/models/transaction_cubit_remove.dart +++ b/lib/data/models/transaction_cubit_remove.dart @@ -22,7 +22,6 @@ import 'node_type.dart'; import 'transaction.dart'; import 'transaction_state.dart'; import 'transaction_type.dart'; -import 'transactions_bloc.dart'; class TransactionCubitRemove extends HydratedCubit<TransactionState> { TransactionCubitRemove() @@ -111,9 +110,9 @@ class TransactionCubitRemove extends HydratedCubit<TransactionState> { txMap[_getTxKey(t)] = t; } // Get a range of tx in 1h - TransactionsBloc().lastTx().forEach((Transaction t) { + for (final Transaction t in newState.transactions) { txMap[_getTxKey(t)] = t; - }); + } for (final Transaction t in newState.pendingTransactions) { pendingMap[_getTxKey(t)] = t; } diff --git a/lib/data/models/transactions_bloc.dart b/lib/data/models/transactions_bloc.dart index edba5cfd6bcd07e4104acde19cd4c8270179f168..b1fbb64562be854f8e79439308af2fcb80a798c2 100644 --- a/lib/data/models/transactions_bloc.dart +++ b/lib/data/models/transactions_bloc.dart @@ -2,9 +2,7 @@ import 'dart:async'; import 'package:rxdart/rxdart.dart'; -import '../../g1/g1_helper.dart'; import '../../ui/logger.dart'; -import '../../ui/pay_helper.dart'; import '../../ui/widgets/connectivity_widget_wrapper_wrapper.dart'; import 'app_cubit.dart'; import 'multi_wallet_transaction_cubit.dart'; @@ -54,18 +52,6 @@ class TransactionsBloc { Sink<String?> get onSearchInputChangedSink => _onSearchInputChangedSubject.sink; - List<Transaction> lastTx({bool applyDateFilter = false}) { - if (_onNewListingStateController.value.itemList != null) { - return _onNewListingStateController.value.itemList! - .where((Transaction tx) => - !applyDateFilter || - areDatesClose(DateTime.now(), tx.time, paymentTimeRange)) - .toList(); - } else { - return <Transaction>[]; - } - } - // String? get _searchInputValue => _onSearchInputChangedSubject.value; Stream<TransactionsState> _resetSearch() async* { diff --git a/lib/g1/g1_helper.dart b/lib/g1/g1_helper.dart index 02165913f78b4f2a0df7d5a75a911ef80da773b6..b2a6721128e547e1987165d62e5dcf23f43700a3 100644 --- a/lib/g1/g1_helper.dart +++ b/lib/g1/g1_helper.dart @@ -14,6 +14,7 @@ import '../data/models/payment_state.dart'; import '../data/models/transaction.dart'; import '../data/models/utxo.dart'; import '../ui/logger.dart'; +import '../ui/pay_helper.dart'; import '../ui/ui_helpers.dart'; Random createRandom() { @@ -370,3 +371,10 @@ bool compareRecipientListsByKey(List<Contact> list1, List<Contact> list2) { return true; } + +List<Transaction> lastTx(List<Transaction> origTxs) { + return origTxs + .where((Transaction tx) => + areDatesClose(DateTime.now(), tx.time, paymentTimeRange)) + .toList(); +}