Removed alert when adding new user

This commit is contained in:
Maximilian P. Käfer 2020-08-23 17:24:55 +02:00
parent 937ccdc956
commit f7c31e566a
2 changed files with 8 additions and 17 deletions

View File

@ -122,13 +122,6 @@ public class ContactSearchTab {
final var user = userList.getSelectionModel().getSelectedItem(); final var user = userList.getSelectionModel().getSelectedItem();
if (user != null) { if (user != null) {
currentlySelectedUser = user; 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); final var event = new ContactOperation(currentlySelectedUser, ElementOperation.ADD);
// Sends the event to the server // Sends the event to the server
eventBus.dispatch(new SendEvent(event)); eventBus.dispatch(new SendEvent(event));
@ -136,7 +129,6 @@ public class ContactSearchTab {
userList.getItems().remove(currentlySelectedUser); userList.getItems().remove(currentlySelectedUser);
eventBus.dispatch(event); eventBus.dispatch(event);
logger.log(Level.INFO, "Added user " + currentlySelectedUser); logger.log(Level.INFO, "Added user " + currentlySelectedUser);
}));
} }
} }

View File

@ -5,7 +5,6 @@
<?import javafx.scene.control.ContextMenu?> <?import javafx.scene.control.ContextMenu?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?> <?import javafx.scene.control.ListView?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TextArea?> <?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
@ -43,7 +42,7 @@
<Insets left="10.0" right="10.0" /> <Insets left="10.0" right="10.0" />
</VBox.margin> </VBox.margin>
<padding> <padding>
<Insets bottom="10.0" top="5.0" /> <Insets bottom="17.0" top="5.0" />
</padding> </padding>
</HBox> </HBox>
<ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS"> <ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">