mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Use crl::on_main_queue for chained init steps.
This commit is contained in:
@@ -181,56 +181,7 @@ Session::Session(
|
|||||||
_selfUserpicView = view.cloud;
|
_selfUserpicView = view.cloud;
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
// Storage::Account uses Main::Account::session() in those methods.
|
crl::on_main_queue(this, { [=] {
|
||||||
// So they can't be called during Main::Session construction.
|
|
||||||
// They are deferred via crl::on_main which fires after the
|
|
||||||
// constructor returns and _session is set.
|
|
||||||
//
|
|
||||||
// Steps are chained via crl::on_main so that paint events
|
|
||||||
// can be processed between heavy file reads.
|
|
||||||
const auto steps = std::make_shared<std::vector<Fn<void()>>>(
|
|
||||||
std::initializer_list<Fn<void()>>{
|
|
||||||
[=] {
|
|
||||||
local().readInstalledStickers();
|
|
||||||
}, [=] {
|
|
||||||
local().readInstalledMasks();
|
|
||||||
}, [=] {
|
|
||||||
local().readInstalledCustomEmoji();
|
|
||||||
}, [=] {
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Stickers);
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Masks);
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Emoji);
|
|
||||||
}, [=] {
|
|
||||||
local().readFeaturedStickers();
|
|
||||||
}, [=] {
|
|
||||||
local().readFeaturedCustomEmoji();
|
|
||||||
}, [=] {
|
|
||||||
local().readRecentStickers();
|
|
||||||
local().readRecentMasks();
|
|
||||||
local().readFavedStickers();
|
|
||||||
local().readSavedGifs();
|
|
||||||
}, [=] {
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Stickers);
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Masks);
|
|
||||||
data().stickers().notifyUpdated(Data::StickersType::Emoji);
|
|
||||||
data().stickers().notifySavedGifsUpdated();
|
|
||||||
DEBUG_LOG(("Init: Account stored data load finished."));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const auto runNext = std::make_shared<Fn<void()>>();
|
|
||||||
*runNext = crl::guard(this, [=] {
|
|
||||||
if (steps->empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto step = std::move(steps->front());
|
|
||||||
steps->erase(steps->begin());
|
|
||||||
step();
|
|
||||||
if (!steps->empty()) {
|
|
||||||
crl::on_main(*runNext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
crl::on_main(this, [=] {
|
|
||||||
using Flag = Data::PeerUpdate::Flag;
|
using Flag = Data::PeerUpdate::Flag;
|
||||||
changes().peerUpdates(
|
changes().peerUpdates(
|
||||||
_user,
|
_user,
|
||||||
@@ -259,9 +210,36 @@ Session::Session(
|
|||||||
});
|
});
|
||||||
saveSettingsDelayed();
|
saveSettingsDelayed();
|
||||||
}
|
}
|
||||||
|
}, [=] {
|
||||||
crl::on_main(*runNext);
|
// Storage::Account uses Main::Account::session() in those methods.
|
||||||
});
|
// So they can't be called during Main::Session construction.
|
||||||
|
//
|
||||||
|
// They are deferred via crl::on_main which fires after the
|
||||||
|
// constructor returns and _session is set.
|
||||||
|
//
|
||||||
|
// Steps are chained via crl::on_main so that paint events
|
||||||
|
// can be processed between heavy file reads.
|
||||||
|
local().readInstalledStickers();
|
||||||
|
}, [=] {
|
||||||
|
local().readInstalledMasks();
|
||||||
|
}, [=] {
|
||||||
|
local().readInstalledCustomEmoji();
|
||||||
|
}, [=] {
|
||||||
|
local().readFeaturedStickers();
|
||||||
|
}, [=] {
|
||||||
|
local().readFeaturedCustomEmoji();
|
||||||
|
}, [=] {
|
||||||
|
local().readRecentStickers();
|
||||||
|
local().readRecentMasks();
|
||||||
|
local().readFavedStickers();
|
||||||
|
local().readSavedGifs();
|
||||||
|
}, [=] {
|
||||||
|
data().stickers().notifyUpdated(Data::StickersType::Stickers);
|
||||||
|
data().stickers().notifyUpdated(Data::StickersType::Masks);
|
||||||
|
data().stickers().notifyUpdated(Data::StickersType::Emoji);
|
||||||
|
data().stickers().notifySavedGifsUpdated();
|
||||||
|
DEBUG_LOG(("Init: Account stored data load finished."));
|
||||||
|
} }).dispatch();
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
||||||
Spellchecker::Start(this);
|
Spellchecker::Start(this);
|
||||||
|
|||||||
+1
-1
Submodule Telegram/lib_crl updated: a41edfcfa8...f770e4e8be
Reference in New Issue
Block a user