From f316dbed439c2dea2c570d6cab1f694f6df6df6f Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 8 Apr 2022 03:24:10 +0200 Subject: Fix a few issues with receiving to_device messages in initial sync --- src/ChatPage.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/ChatPage.cpp') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 43455e86..0550c7f3 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -560,25 +560,26 @@ ChatPage::startInitialSync() } } - nhlog::net()->info("initial sync completed"); - - try { - cache::client()->saveState(res); + QTimer::singleShot(0, this, [this, res] { + nhlog::net()->info("initial sync completed"); + 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(); + }); }); } -- cgit 1.5.1