aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/message_storage.vala
diff options
context:
space:
mode:
authorbobufa <bobufa@users.noreply.github.com>2018-06-19 18:07:00 +0200
committerbobufa <bobufa@users.noreply.github.com>2018-08-13 22:04:47 +0200
commit3ea00446fb5893804243f5b1a1aa89817b7bc19a (patch)
tree3be25cfd7b807cd6db4846e6fe1b6e404a58a1f4 /libdino/src/service/message_storage.vala
parentab0bc7f04d156db9e398c3f8c4f8bdfc11dd7458 (diff)
downloaddino-3ea00446fb5893804243f5b1a1aa89817b7bc19a.tar.gz
dino-3ea00446fb5893804243f5b1a1aa89817b7bc19a.zip
refactor conversation item management (accumulate them in libdino)
Diffstat (limited to 'libdino/src/service/message_storage.vala')
-rw-r--r--libdino/src/service/message_storage.vala32
1 files changed, 16 insertions, 16 deletions
diff --git a/libdino/src/service/message_storage.vala b/libdino/src/service/message_storage.vala
index 35e05074..906693a3 100644
--- a/libdino/src/service/message_storage.vala
+++ b/libdino/src/service/message_storage.vala
@@ -51,23 +51,23 @@ public class MessageStorage : StreamInteractionModule, Object {
return null;
}
- public Gee.List<Message>? get_messages_before_message(Conversation? conversation, Message message, int count = 20) {
- SortedSet<Message>? before = messages[conversation].head_set(message);
- if (before != null && before.size >= count) {
- Gee.List<Message> ret = new ArrayList<Message>(Message.equals_func);
- Iterator<Message> iter = before.iterator();
- iter.next();
- for (int from_index = before.size - count; iter.has_next() && from_index > 0; from_index--) iter.next();
- while(iter.has_next()) {
- Message m = iter.get();
- ret.add(m);
- iter.next();
- }
- return ret;
- } else {
- Gee.List<Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, Util.get_message_type_for_conversation(conversation), count, message.local_time);
+ public Gee.List<Message>? get_messages_before_message(Conversation? conversation, DateTime before, int count = 20) {
+// SortedSet<Message>? before = messages[conversation].head_set(message);
+// if (before != null && before.size >= count) {
+// Gee.List<Message> ret = new ArrayList<Message>(Message.equals_func);
+// Iterator<Message> iter = before.iterator();
+// iter.next();
+// for (int from_index = before.size - count; iter.has_next() && from_index > 0; from_index--) iter.next();
+// while(iter.has_next()) {
+// Message m = iter.get();
+// ret.add(m);
+// iter.next();
+// }
+// return ret;
+// } else {
+ Gee.List<Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, Util.get_message_type_for_conversation(conversation), count, before);
return db_messages;
- }
+// }
}
public Message? get_message_by_id(string stanza_id, Conversation conversation) {