From 63990f6d5700ea21e4e69817dcd3d2a3fe35a18b Mon Sep 17 00:00:00 2001 From: kske Date: Mon, 3 Feb 2020 06:57:19 +0100 Subject: [PATCH] Fixed message reading --- src/main/java/envoy/client/Chat.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/envoy/client/Chat.java b/src/main/java/envoy/client/Chat.java index a00e46d..b51f068 100644 --- a/src/main/java/envoy/client/Chat.java +++ b/src/main/java/envoy/client/Chat.java @@ -45,15 +45,18 @@ public class Chat implements Serializable { public void appendMessage(Message message) { model.add(message); } /** - * Sets the status of all chat messages to {@code READ} starting from the bottom - * and stopping once a read message is found. - * + * Sets the status of all chat messages received from the recipient to + * {@code READ} starting from the bottom and stopping once a read message is + * found. + * * @since Envoy v0.3-alpha */ public void read() { for (int i = model.size() - 1; i >= 0; --i) - if (model.get(i).getStatus() == MessageStatus.READ) break; - else model.get(i).setStatus(MessageStatus.READ); + if (model.get(i).getSenderId() == recipient.getId()) { + if (model.get(i).getStatus() == MessageStatus.READ) break; + else model.get(i).setStatus(MessageStatus.READ); + } } /**