From 3af381957f298e3033a412e05953aaa3c12ac8f3 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 27 Mar 2017 23:30:27 -0500 Subject: [PATCH] Fix missing state reset. dont delay if we switch trades --- .../pendingtrades/PendingTradesViewModel.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/PendingTradesViewModel.java b/gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/PendingTradesViewModel.java index 7007ee942e..8a5ff698d7 100644 --- a/gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/gui/src/main/java/io/bisq/gui/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -121,9 +121,11 @@ public class PendingTradesViewModel extends ActivatableWithDataModel { - // We might get a higher state set quickly (startup - stored state, then new state) - // and then we don't want to switch back - if (buyerState.get() == null || buyerState.get().ordinal() < BuyerState.STEP3.ordinal()) - buyerState.set(BuyerState.STEP3); - }, 1); + // If we switch quickly we want to get to our state again without delay + if (buyerState.get() == null || buyerState.get() == BuyerState.UNDEFINED) { + buyerState.set(BuyerState.STEP3); + } else { + // We delay the UI switch to give a chance to see the delivery result + UserThread.runAfter(() -> { + // We might get a higher state set quickly (startup - stored state, then new state) + // and then we don't want to switch back + if (buyerState.get() == null || buyerState.get().ordinal() < BuyerState.STEP3.ordinal()) + buyerState.set(BuyerState.STEP3); + }, 1); + } break; // seller step 3 @@ -415,16 +422,21 @@ public class PendingTradesViewModel extends ActivatableWithDataModel { - // We might get a higher state set quickly (startup - stored state, then new state) - // and then we don't want to switch back - if (sellerState.get() == null || sellerState.get().ordinal() < SellerState.STEP4.ordinal()) - sellerState.set(SellerState.STEP4); - }, 1); - break; + // If we switch quickly we want to get to our state again without delay + if (sellerState.get() == null || sellerState.get() == UNDEFINED) { + sellerState.set(SellerState.STEP4); + } else { + // We delay the UI switch to give a chance to see the delivery result + UserThread.runAfter(() -> { + // We might get a higher state set quickly (startup - stored state, then new state) + // and then we don't want to switch back + if (sellerState.get() == null || sellerState.get().ordinal() < SellerState.STEP4.ordinal()) + sellerState.set(SellerState.STEP4); + }, 1); + break; + } - // buyer step 4 + // buyer step 4 case BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG: // Alternatively the maker could have seen the payout tx earlier before he received the PAYOUT_TX_PUBLISHED_MSG: case BUYER_SAW_PAYOUT_TX_IN_NETWORK: