Fix the old account isn't replaced when adding a same account
This commit is contained in:
@@ -152,8 +152,9 @@ public class AddAccountPane extends StackPane {
|
|||||||
Accounts.getAccounts().add(account);
|
Accounts.getAccounts().add(account);
|
||||||
} else {
|
} else {
|
||||||
// adding an already-added account
|
// adding an already-added account
|
||||||
// instead of discarding the new account, we replace the existing account with the new account
|
// instead of discarding the new account, we first remove the existing one then add the new one
|
||||||
Accounts.getAccounts().set(oldIndex, account);
|
Accounts.getAccounts().remove(oldIndex);
|
||||||
|
Accounts.getAccounts().add(oldIndex, account);
|
||||||
}
|
}
|
||||||
acceptPane.hideSpinner();
|
acceptPane.hideSpinner();
|
||||||
fireEvent(new DialogCloseEvent());
|
fireEvent(new DialogCloseEvent());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static javafx.collections.FXCollections.unmodifiableObservableList;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -75,7 +75,7 @@ public final class MappedObservableList {
|
|||||||
@Override
|
@Override
|
||||||
public void onChanged(Change<? extends T> change) {
|
public void onChanged(Change<? extends T> change) {
|
||||||
// cache removed elements to reduce calls to mapper
|
// cache removed elements to reduce calls to mapper
|
||||||
Map<T, LinkedList<U>> cache = new HashMap<>();
|
Map<T, LinkedList<U>> cache = new IdentityHashMap<>();
|
||||||
|
|
||||||
while (change.next()) {
|
while (change.next()) {
|
||||||
int from = change.getFrom();
|
int from = change.getFrom();
|
||||||
|
|||||||
Reference in New Issue
Block a user