Fix a few issues with receiving to_device messages in initial sync

This commit is contained in:
Nicolas Werner 2022-04-08 03:24:10 +02:00
parent 66b7ff639c
commit f316dbed43
5 changed files with 33 additions and 23 deletions

View file

@ -560,25 +560,26 @@ ChatPage::startInitialSync()
}
}
nhlog::net()->info("initial sync completed");
QTimer::singleShot(0, this, [this, res] {
nhlog::net()->info("initial sync completed");
try {
cache::client()->saveState(res);
try {
cache::client()->saveState(res);
olm::handle_to_device_messages(res.to_device.events);
olm::handle_to_device_messages(res.to_device.events);
emit initializeViews(std::move(res));
emit initializeMentions(cache::getTimelineMentions());
emit initializeViews(std::move(res));
emit initializeMentions(cache::getTimelineMentions());
cache::calculateRoomReadStatus();
} catch (const lmdb::error &e) {
nhlog::db()->error("failed to save state after initial sync: {}", e.what());
startInitialSync();
return;
}
cache::calculateRoomReadStatus();
} catch (const lmdb::error &e) {
nhlog::db()->error("failed to save state after initial sync: {}", e.what());
startInitialSync();
return;
}
emit trySyncCb();
emit contentLoaded();
emit trySyncCb();
emit contentLoaded();
});
});
}