diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-22 17:52:27 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-05-22 17:52:27 +0200 |
commit | e5b8302fd9a09552f0b33a956703751bf9da80a7 (patch) | |
tree | 8e9493c326b39f62d8c73b99443c106e71508303 /src/main/java/eu/siacs/conversations/entities | |
parent | 33218ec32a47292a46d574e5107164b8e8a72e40 (diff) |
show first unread message on top after reinit
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Conversation.java | 15 |
1 files changed, 15 insertions, 0 deletions
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) { |