From f77795edb1a0bd93114c6d8e05b96c8ed72a88ba Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sun, 23 Aug 2020 17:24:55 +0200 Subject: [PATCH] Removed alert when adding new user --- .../ui/controller/ContactSearchTab.java | 22 ++++++------------- .../main/resources/fxml/ContactSearchTab.fxml | 3 +-- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java b/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java index 22b16e0..1ffb842 100644 --- a/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java +++ b/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java @@ -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); } } diff --git a/client/src/main/resources/fxml/ContactSearchTab.fxml b/client/src/main/resources/fxml/ContactSearchTab.fxml index 93c1ca4..8bde8d9 100644 --- a/client/src/main/resources/fxml/ContactSearchTab.fxml +++ b/client/src/main/resources/fxml/ContactSearchTab.fxml @@ -5,7 +5,6 @@ - @@ -43,7 +42,7 @@ - +