From d6de1be7de584bdd87848677b967bc5466aa3508 Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 4 Jul 2020 15:27:42 +0200 Subject: [PATCH] Partially fixed bug not showing "Add user to contact list?" - Alert --- .../envoy/client/ui/controller/ContactSearchScene.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java index 957a52b..4fe48d2 100644 --- a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java +++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java @@ -101,14 +101,17 @@ public class ContactSearchScene { final var alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Add Contact to Contact List"); alert.setHeaderText("Add the user " + contact.getName() + " to your contact list?"); - alert.showAndWait().filter(btn -> btn == ButtonType.OK).ifPresent(btn -> { + // 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(contact, ElementOperation.ADD); // Sends the event to the server eventBus.dispatch(new SendEvent(event)); // Updates the UI eventBus.dispatch(event); logger.log(Level.INFO, "Added contact " + contact); - }); + })); } }