Skip to content

Commit d305476

Browse files
committed
Load only accent colors in ThemeManager constructor.
1 parent 3870c29 commit d305476

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

td/telegram/ThemeManager.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,14 @@ void ThemeManager::AccentColors::parse(ParserT &parser) {
182182
}
183183

184184
ThemeManager::ThemeManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
185-
do_init();
185+
load_accent_colors();
186186
}
187187

188-
void ThemeManager::do_init() {
188+
void ThemeManager::start_up() {
189+
init();
190+
}
191+
192+
void ThemeManager::load_chat_themes() { // must not be called in constructor, because uses other managers
189193
if (!td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
190194
return;
191195
}
@@ -201,8 +205,14 @@ void ThemeManager::do_init() {
201205
}
202206
}
203207
chat_themes_.next_reload_time = Time::now();
208+
}
209+
210+
void ThemeManager::load_accent_colors() {
211+
if (!td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
212+
return;
213+
}
204214

205-
log_event_string = G()->td_db()->get_binlog_pmc()->get(get_accent_colors_database_key());
215+
auto log_event_string = G()->td_db()->get_binlog_pmc()->get(get_accent_colors_database_key());
206216
if (!log_event_string.empty()) {
207217
auto status = log_event_parse(accent_colors_, log_event_string);
208218
if (status.is_ok()) {
@@ -215,7 +225,7 @@ void ThemeManager::do_init() {
215225
}
216226

217227
void ThemeManager::init() {
218-
do_init();
228+
load_chat_themes();
219229
loop();
220230
}
221231

td/telegram/ThemeManager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,15 @@ class ThemeManager final : public Actor {
106106
void parse(ParserT &parser);
107107
};
108108

109+
void start_up() final;
110+
109111
void loop() final;
110112

111113
void tear_down() final;
112114

113-
void do_init();
115+
void load_chat_themes();
116+
117+
void load_accent_colors();
114118

115119
static bool is_dark_base_theme(BaseTheme base_theme);
116120

0 commit comments

Comments
 (0)