mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Fix a few more bugs where a limited timeline could cause a hanging pagination
This commit is contained in:
parent
7fc7aa2da3
commit
21889f00e7
1 changed files with 15 additions and 2 deletions
|
@ -3624,6 +3624,19 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
||||||
if (redaction->redacts.empty())
|
if (redaction->redacts.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// persist the first redaction in case this is a limited timeline and it is the first
|
||||||
|
// event to not break pagination.
|
||||||
|
if (first && res.limited) {
|
||||||
|
first = false;
|
||||||
|
++index;
|
||||||
|
|
||||||
|
nhlog::db()->debug("saving redaction '{}'", orderEntry.dump());
|
||||||
|
|
||||||
|
cursor.put(lmdb::to_sv(index), orderEntry.dump(), MDB_APPEND);
|
||||||
|
evToOrderDb.put(txn, event_id, lmdb::to_sv(index));
|
||||||
|
eventsDb.put(txn, event_id, event.dump());
|
||||||
|
}
|
||||||
|
|
||||||
std::string_view oldEvent;
|
std::string_view oldEvent;
|
||||||
bool success = eventsDb.get(txn, redaction->redacts, oldEvent);
|
bool success = eventsDb.get(txn, redaction->redacts, oldEvent);
|
||||||
if (!success)
|
if (!success)
|
||||||
|
@ -3671,13 +3684,13 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
|
||||||
eventsDb.put(txn, redaction->redacts, event.dump());
|
eventsDb.put(txn, redaction->redacts, event.dump());
|
||||||
eventsDb.put(txn, redaction->event_id, nlohmann::json(*redaction).dump());
|
eventsDb.put(txn, redaction->event_id, nlohmann::json(*redaction).dump());
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
|
||||||
|
|
||||||
// This check protects against duplicates in the timeline. If the event_id
|
// This check protects against duplicates in the timeline. If the event_id
|
||||||
// is already in the DB, we skip putting it (again) in ordered DBs, and only
|
// is already in the DB, we skip putting it (again) in ordered DBs, and only
|
||||||
// update the event itself and its relations.
|
// update the event itself and its relations.
|
||||||
std::string_view unused_read;
|
std::string_view unused_read;
|
||||||
if (!evToOrderDb.get(txn, event_id, unused_read)) {
|
if (!evToOrderDb.get(txn, event_id, unused_read)) {
|
||||||
|
first = false;
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
|
|
||||||
nhlog::db()->debug("saving '{}'", orderEntry.dump());
|
nhlog::db()->debug("saving '{}'", orderEntry.dump());
|
||||||
|
|
Loading…
Reference in a new issue