Removed alert when adding new user
This commit is contained in:
@ -122,21 +122,13 @@ public class ContactSearchTab {
|
||||
final var user = userList.getSelectionModel().getSelectedItem();
|
||||
if (user != null) {
|
||||
currentlySelectedUser = user;
|
||||
alert = new Alert(AlertType.CONFIRMATION);
|
||||
alert.setTitle("Add User to Contact List");
|
||||
alert.setHeaderText("Add the user " + currentlySelectedUser.getName() + " to your contact list?");
|
||||
// Normally, this would be total BS (we are already on the FX Thread), however
|
||||
// it could be proven that the creation of this dialog wrapped in
|
||||
// Platform.runLater is less error-prone than without it
|
||||
Platform.runLater(() -> alert.showAndWait().filter(btn -> btn == ButtonType.OK).ifPresent(btn -> {
|
||||
final var event = new ContactOperation(currentlySelectedUser, ElementOperation.ADD);
|
||||
// Sends the event to the server
|
||||
eventBus.dispatch(new SendEvent(event));
|
||||
// Removes the chosen user and updates the UI
|
||||
userList.getItems().remove(currentlySelectedUser);
|
||||
eventBus.dispatch(event);
|
||||
logger.log(Level.INFO, "Added user " + currentlySelectedUser);
|
||||
}));
|
||||
final var event = new ContactOperation(currentlySelectedUser, ElementOperation.ADD);
|
||||
// Sends the event to the server
|
||||
eventBus.dispatch(new SendEvent(event));
|
||||
// Removes the chosen user and updates the UI
|
||||
userList.getItems().remove(currentlySelectedUser);
|
||||
eventBus.dispatch(event);
|
||||
logger.log(Level.INFO, "Added user " + currentlySelectedUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user