Skip to content

Commit

Permalink
Add isCloneOfferViewActivated flag to avoid repeated code execution i…
Browse files Browse the repository at this point in the history
…n doActivate.

Do not create a new observableArrayList in filterPaymentAccounts.

The reason why the wrong account gets selected is not completely clear to me. The selection handler gets called when the combobox gets filled and that overwrites the selected account from the data. It seems that the new observableArrayList in filterPaymentAccounts triggered that un-expected behaviour.
  • Loading branch information
HenrikJannsen committed May 20, 2023
1 parent 8c37ddd commit dbd1098
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
import javafx.geometry.Insets;
import javafx.geometry.Pos;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import java.util.List;
import java.util.stream.Collectors;

import static bisq.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup;
Expand Down Expand Up @@ -102,6 +102,7 @@ protected void doSetFocus() {
protected void doActivate() {
super.doActivate();


addBindings();

hideOptionsGroup();
Expand Down Expand Up @@ -130,17 +131,17 @@ protected void doActivate() {
onPaymentAccountsComboBoxSelected();
}

@Override
public void onClose() {
}

@Override
protected void deactivate() {
super.deactivate();

removeBindings();
}

@Override
public void onClose() {
}

///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -174,12 +175,15 @@ private void removeBindings() {
@Override
protected ObservableList<PaymentAccount> filterPaymentAccounts(ObservableList<PaymentAccount> paymentAccounts) {
// We do not allow cloning or BSQ as there is no maker fee and requirement for reserved funds.
return FXCollections.observableArrayList(
paymentAccounts.stream()
.filter(paymentAccount -> !GUIUtil.BSQ.equals(paymentAccount.getSingleTradeCurrency()))
.collect(Collectors.toList()));
// Do not create a new ObservableList as that would cause bugs with the selected account.
List<PaymentAccount> toRemove = paymentAccounts.stream()
.filter(paymentAccount -> GUIUtil.BSQ.equals(paymentAccount.getSingleTradeCurrency()))
.collect(Collectors.toList());
toRemove.forEach(paymentAccounts::remove);
return paymentAccounts;
}


///////////////////////////////////////////////////////////////////////////////////////////
// Build UI elements
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit dbd1098

Please sign in to comment.