diff options
author | bobufa <bobufa@users.noreply.github.com> | 2018-06-23 11:59:21 +0200 |
---|---|---|
committer | bobufa <bobufa@users.noreply.github.com> | 2018-08-13 22:05:04 +0200 |
commit | 760fd4cb26340165fb85c2e3aee8390e46dc8b63 (patch) | |
tree | e68f93a234680b4d84fd79b02cd27c6f1b058077 /libdino/src/service/database.vala | |
parent | 443e7ee49da305a9ae8052c5b7a73412d03ce75f (diff) | |
download | dino-760fd4cb26340165fb85c2e3aee8390e46dc8b63.tar.gz dino-760fd4cb26340165fb85c2e3aee8390e46dc8b63.zip |
load+display later messages when scrolling down
Diffstat (limited to 'libdino/src/service/database.vala')
-rw-r--r-- | libdino/src/service/database.vala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 2dca686f..d02e4c71 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -236,11 +236,10 @@ public class Database : Qlite.Database { } } - public Gee.List<Message> get_messages(Xmpp.Jid jid, Account account, Message.Type? type, int count, DateTime? before) { + public Gee.List<Message> get_messages(Xmpp.Jid jid, Account account, Message.Type? type, int count, DateTime? before, DateTime? after, int id) { QueryBuilder select = message.select() .with(message.counterpart_id, "=", get_jid_id(jid)) .with(message.account_id, "=", account.id) - .order_by(message.id, "DESC") .limit(count); if (jid.resourcepart != null) { select.with(message.counterpart_resource, "=", jid.resourcepart); @@ -250,6 +249,17 @@ public class Database : Qlite.Database { } if (before != null) { select.with(message.local_time, "<", (long) before.to_unix()); + if (id > 0) { + select.with(message.id, "<", id); + } + } + if (after != null) { + select.with(message.local_time, ">", (long) after.to_unix()); + if (id > 0) { + select.with(message.id, ">", id); + } + } else { + select.order_by(message.id, "DESC"); } LinkedList<Message> ret = new LinkedList<Message>(); |