From dad05449cf623feeec58b8b9343d55e0a382ed6d Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 26 Jun 2020 09:28:48 +0200 Subject: [PATCH] Fix double status increment on cached message relay --- src/main/java/envoy/client/data/Cache.java | 7 +++++-- src/main/java/envoy/client/net/WriteProxy.java | 3 --- src/main/java/envoy/client/ui/controller/ChatScene.java | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/envoy/client/data/Cache.java b/src/main/java/envoy/client/data/Cache.java index 0707a62..786e96b 100644 --- a/src/main/java/envoy/client/data/Cache.java +++ b/src/main/java/envoy/client/data/Cache.java @@ -10,8 +10,8 @@ import java.util.logging.Logger; import envoy.util.EnvoyLog; /** - * Stores elements in a queue to process them later.
- *
+ * Stores elements in a queue to process them later. + *

* Project: envoy-client
* File: Cache.java
* Created: 6 Feb 2020
@@ -40,6 +40,9 @@ public class Cache implements Consumer, Serializable { elements.offer(element); } + @Override + public String toString() { return String.format("Cache[elements=" + elements + "]"); } + /** * Sets the processor to which cached elements are relayed. * diff --git a/src/main/java/envoy/client/net/WriteProxy.java b/src/main/java/envoy/client/net/WriteProxy.java index 2287369..90e49e0 100644 --- a/src/main/java/envoy/client/net/WriteProxy.java +++ b/src/main/java/envoy/client/net/WriteProxy.java @@ -47,9 +47,6 @@ public class WriteProxy { try { logger.log(Level.FINER, "Sending cached " + msg); client.sendMessage(msg); - - // Update message state to SENT in localDB - localDB.getMessage(msg.getID()).ifPresent(Message::nextStatus); } catch (final IOException e) { logger.log(Level.SEVERE, "Could not send cached message: ", e); } diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index d64ef48..ff93351 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -164,6 +164,7 @@ public final class ChatScene { private void userListClicked() { final Contact user = userList.getSelectionModel().getSelectedItem(); if (user != null && (currentChat == null || !user.equals(currentChat.getRecipient()))) { + logger.log(Level.FINEST, "Loading chat with " + user); contactLabel.setText(user.getName()); // LEON: JFC <===> JAVA FRIED CHICKEN <=/=> Java Foundation Classes