From 096282032b3ba2be2fdf1161e31c2097aa080f56 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Thu, 21 Nov 2024 12:09:28 -0700 Subject: [PATCH] consistently order unspent coins / prevent coins jumping around --- .../unspent_coins/unspent_coins_list_view_model.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart index f16b8390f..d01d97efb 100644 --- a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart +++ b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart @@ -146,6 +146,15 @@ abstract class UnspentCoinsListViewModelBase with Store { } }); + // sort by hash so that even if the addresses are the same, they don't jump around when selected (because that calls updateBalance) + unspents.sort((a, b) => a.hash.compareTo(b.hash)); + + // sort unspents by address so that if something changes it's easier to see: + unspents.sort((a, b) => a.address.compareTo(b.address)); + + // sort change addresses to the end: + // unspents.sort((a, b) => a.isChange ? 1 : -1); + _items.addAll(unspents); } }