Fixed bug duplicating messages
This commit is contained in:
		@@ -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());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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")
 | 
			
		||||
 
 | 
			
		||||
@@ -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: <strong>envoy-client</strong><br>
 | 
			
		||||
@@ -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));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user