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/file_manager.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/file_manager.vala')
-rw-r--r-- | libdino/src/service/file_manager.vala | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala index 667076dd..18f1735d 100644 --- a/libdino/src/service/file_manager.vala +++ b/libdino/src/service/file_manager.vala @@ -84,13 +84,7 @@ public class FileManager : StreamInteractionModule, Object { .with(db.file_transfer.account_id, "=", account.id) .order_by(db.file_transfer.local_time, "DESC") .limit(n); - - Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>(); - foreach (Qlite.Row row in select) { - FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir()); - ret.insert(0, file_transfer); - } - return ret; + return get_transfers_from_qry(select); } public Gee.List<FileTransfer> get_transfers_before(Account account, Jid counterpart, DateTime before, int n) { @@ -100,23 +94,19 @@ public class FileManager : StreamInteractionModule, Object { .with(db.file_transfer.local_time, "<", (long)before.to_unix()) .order_by(db.file_transfer.local_time, "DESC") .limit(n); - - Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>(); - foreach (Qlite.Row row in select) { - FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir()); - ret.insert(0, file_transfer); - } - return ret; + return get_transfers_from_qry(select); } - public Gee.List<FileTransfer> get_file_transfers(Account account, Jid counterpart, DateTime after, DateTime before) { + public Gee.List<FileTransfer> get_transfers_after(Account account, Jid counterpart, DateTime after, int n) { Qlite.QueryBuilder select = db.file_transfer.select() .with(db.file_transfer.counterpart_id, "=", db.get_jid_id(counterpart)) .with(db.file_transfer.account_id, "=", account.id) .with(db.file_transfer.local_time, ">", (long)after.to_unix()) - .with(db.file_transfer.local_time, "<", (long)before.to_unix()) - .order_by(db.file_transfer.id, "DESC"); + .limit(n); + return get_transfers_from_qry(select); + } + private Gee.List<FileTransfer> get_transfers_from_qry(Qlite.QueryBuilder select) { Gee.List<FileTransfer> ret = new ArrayList<FileTransfer>(); foreach (Qlite.Row row in select) { FileTransfer file_transfer = new FileTransfer.from_row(db, row, get_storage_dir()); |