From 00edd59f977d753fb2a3e3d99773aad358ae64cb Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 18 Apr 2020 10:34:03 +0200 Subject: [PATCH] Fixed bug duplicating messages --- src/main/java/envoy/client/net/Client.java | 2 +- src/main/java/envoy/client/net/Receiver.java | 2 +- .../java/envoy/client/ui/ChatSceneController.java | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index 2440d8b..00a6ddf 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -231,7 +231,7 @@ public class Client implements Closeable { private void writeObject(Object obj) throws IOException { checkOnline(); - logger.fine("Sending object " + obj); + logger.fine("Sending " + obj); SerializationUtils.writeBytesWithLength(obj, socket.getOutputStream()); } diff --git a/src/main/java/envoy/client/net/Receiver.java b/src/main/java/envoy/client/net/Receiver.java index bdaf853..b3dd763 100644 --- a/src/main/java/envoy/client/net/Receiver.java +++ b/src/main/java/envoy/client/net/Receiver.java @@ -54,7 +54,7 @@ public class Receiver extends Thread { try (ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(objBytes))) { Object obj = oin.readObject(); - logger.fine("Received object " + obj); + logger.fine("Received " + obj); // Get appropriate processor @SuppressWarnings("rawtypes") diff --git a/src/main/java/envoy/client/ui/ChatSceneController.java b/src/main/java/envoy/client/ui/ChatSceneController.java index b8927d4..f6d9b4f 100644 --- a/src/main/java/envoy/client/ui/ChatSceneController.java +++ b/src/main/java/envoy/client/ui/ChatSceneController.java @@ -5,6 +5,13 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; + import envoy.client.data.Chat; import envoy.client.data.LocalDB; import envoy.client.event.MessageCreationEvent; @@ -17,12 +24,6 @@ import envoy.event.EventBus; import envoy.event.MessageStatusChangeEvent; import envoy.event.UserStatusChangeEvent; import envoy.util.EnvoyLog; -import javafx.application.Platform; -import javafx.collections.FXCollections; -import javafx.fxml.FXML; -import javafx.scene.control.*; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; /** * Project: envoy-client
@@ -72,7 +73,6 @@ public final class ChatSceneController { eventBus.register(MessageCreationEvent.class, e -> { final var message = e.get(); final var chat = localDB.getChats().stream().filter(c -> c.getRecipient().getID() == message.getSenderID()).findAny().get(); - chat.getMessages().add(message); // Update UI if in current chat if (chat == currentChat) Platform.runLater(() -> messageList.getItems().add(message));