summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-10-23 19:42:12 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2020-10-23 19:42:23 +0200
commit4797b9fa9651c2bb5a35ca67497c2f0eb4956820 (patch)
treec25af0ef6625dc99cd04a7b564743d5a97edefcd /src/Cache.cpp
parentFix share keys setting not working (diff)
downloadnheko-4797b9fa9651c2bb5a35ca67497c2f0eb4956820.tar.xz
Fix infinite pagination properly now.
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 090af913..3ffa9fd2 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -2712,8 +2712,19 @@ Cache::saveOldMessages(const std::string &room_id, const mtx::responses::Message } } - if (res.chunk.empty()) + if (res.chunk.empty()) { + if (lmdb::dbi_get(txn, orderDb, lmdb::val(&index, sizeof(index)), val)) { + auto orderEntry = json::parse(std::string_view(val.data(), val.size())); + orderEntry["prev_batch"] = res.end; + lmdb::dbi_put(txn, + orderDb, + lmdb::val(&index, sizeof(index)), + lmdb::val(orderEntry.dump())); + nhlog::db()->debug("saving '{}'", orderEntry.dump()); + txn.commit(); + } return index; + } std::string event_id_val; for (const auto &e : res.chunk) {