From 69934fb87103c7b647d4ba690b1077cece21a57c Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 31 Jan 2023 09:42:55 -0600 Subject: [PATCH] clean up transaction list item ui state update key --- .../sub_widgets/transactions_list.dart | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index 360b3028b..0c48e69b6 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -20,6 +20,8 @@ import 'package:stackwallet/widgets/trade_card.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../utilities/enums/coin_enum.dart'; + class TransactionsList extends ConsumerStatefulWidget { const TransactionsList({ Key? key, @@ -67,11 +69,18 @@ class _TransactionsListState extends ConsumerState { BuildContext context, Transaction tx, BorderRadius? radius, + Coin coin, ) { final matchingTrades = ref .read(tradesServiceProvider) .trades .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); + + final isConfirmed = tx.isConfirmed( + ref.watch( + widget.managerProvider.select((value) => value.currentHeight)), + coin.requiredConfirmations); + if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { final trade = matchingTrades.first; return Container( @@ -84,13 +93,9 @@ class _TransactionsListState extends ConsumerState { children: [ TransactionCard( // this may mess with combined firo transactions - key: Key(tx.txid + - tx.type.name + - tx.address.value.toString() + - ref - .watch(widget.managerProvider - .select((value) => value.currentHeight)) - .toString()), // + key: isConfirmed + ? Key(tx.txid + tx.type.name + tx.address.value.toString()) + : UniqueKey(), // transaction: tx, walletId: widget.walletId, ), @@ -185,13 +190,9 @@ class _TransactionsListState extends ConsumerState { ), child: TransactionCard( // this may mess with combined firo transactions - key: Key(tx.txid + - tx.type.name + - tx.address.value.toString() + - ref - .watch(widget.managerProvider - .select((value) => value.currentHeight)) - .toString()), // + key: isConfirmed + ? Key(tx.txid + tx.type.name + tx.address.value.toString()) + : UniqueKey(), transaction: tx, walletId: widget.walletId, ), @@ -263,7 +264,7 @@ class _TransactionsListState extends ConsumerState { radius = _borderRadiusFirst; } final tx = _transactions2[index]; - return itemBuilder(context, tx, radius); + return itemBuilder(context, tx, radius, manager.coin); }, separatorBuilder: (context, index) { return Container( @@ -290,7 +291,7 @@ class _TransactionsListState extends ConsumerState { radius = _borderRadiusFirst; } final tx = _transactions2[index]; - return itemBuilder(context, tx, radius); + return itemBuilder(context, tx, radius, manager.coin); }, ), );