From e5b8302fd9a09552f0b33a956703751bf9da80a7 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 22 May 2016 17:52:27 +0200 Subject: show first unread message on top after reinit --- .../eu/siacs/conversations/entities/Conversation.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main/java/eu/siacs/conversations/entities') diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 10b42b460..23420d69a 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -96,6 +96,21 @@ public class Conversation extends AbstractEntity implements Blockable { this.messagesLeftOnServer = value; } + + public Message getFirstUnreadMessage() { + Message first = null; + synchronized (this.messages) { + for (int i = messages.size() - 1; i >= 0; --i) { + if (messages.get(i).isRead()) { + return first; + } else { + first = messages.get(i); + } + } + } + return first; + } + public Message findUnsentMessageWithUuid(String uuid) { synchronized(this.messages) { for (final Message message : this.messages) { -- cgit v1.2.3