Removed alert when adding new user
This commit is contained in:
parent
dbf69c7cc1
commit
f77795edb1
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
<?import javafx.scene.control.ContextMenu?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
@ -43,7 +42,7 @@
|
||||
<Insets left="10.0" right="10.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="10.0" top="5.0" />
|
||||
<Insets bottom="17.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
|
||||
|
Reference in New Issue
Block a user