From ebf8d7ab01bd9df03c3a9fda0f0e2c5da228c8ce Mon Sep 17 00:00:00 2001 From: Translations Date: Sat, 18 Nov 2017 19:42:22 +0100 Subject: Update translations --- libdino/src/service/message_storage.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'libdino/src/service') diff --git a/libdino/src/service/message_storage.vala b/libdino/src/service/message_storage.vala index 76a8e60d..97873972 100644 --- a/libdino/src/service/message_storage.vala +++ b/libdino/src/service/message_storage.vala @@ -32,9 +32,11 @@ public class MessageStorage : StreamInteractionModule, Object { public Gee.List get_messages(Conversation conversation, int count = 50) { init_conversation(conversation); Gee.List ret = new ArrayList(Message.equals_func); - foreach (Message message in messages[conversation]) { - if (ret.size >= count) break; - ret.add(message); + BidirIterator iter = messages[conversation].bidir_iterator(); + iter.last(); + while (iter.valid && ret.size < count) { + iter.previous(); + ret.insert(0, iter.get()); } return ret; } @@ -42,7 +44,7 @@ public class MessageStorage : StreamInteractionModule, Object { public Message? get_last_message(Conversation conversation) { init_conversation(conversation); if (messages[conversation].size > 0) { - return messages[conversation].first(); + return messages[conversation].last(); } return null; } @@ -62,7 +64,7 @@ public class MessageStorage : StreamInteractionModule, Object { private void init_conversation(Conversation conversation) { if (!messages.has_key(conversation)) { - messages[conversation] = new Gee.TreeSet((a, b) => { return -1 * a.local_time.compare(b.local_time); }); + messages[conversation] = new Gee.TreeSet((a, b) => { return a.local_time.compare(b.local_time); }); Gee.List db_messages = db.get_messages(conversation.counterpart, conversation.account, Util.get_message_type_for_conversation(conversation), 50, null); messages[conversation].add_all(db_messages); } -- cgit v1.2.3-70-g09d2