Skip to content

Commit

Permalink
Load only accent colors in ThemeManager constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Nov 6, 2023
1 parent 3870c29 commit d305476
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 14 additions & 4 deletions td/telegram/ThemeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ void ThemeManager::AccentColors::parse(ParserT &parser) {
}

ThemeManager::ThemeManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
do_init();
load_accent_colors();
}

void ThemeManager::do_init() {
void ThemeManager::start_up() {
init();
}

void ThemeManager::load_chat_themes() { // must not be called in constructor, because uses other managers
if (!td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
return;
}
Expand All @@ -201,8 +205,14 @@ void ThemeManager::do_init() {
}
}
chat_themes_.next_reload_time = Time::now();
}

void ThemeManager::load_accent_colors() {
if (!td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot()) {
return;
}

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

void ThemeManager::init() {
do_init();
load_chat_themes();
loop();
}

Expand Down
6 changes: 5 additions & 1 deletion td/telegram/ThemeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ class ThemeManager final : public Actor {
void parse(ParserT &parser);
};

void start_up() final;

void loop() final;

void tear_down() final;

void do_init();
void load_chat_themes();

void load_accent_colors();

static bool is_dark_base_theme(BaseTheme base_theme);

Expand Down

0 comments on commit d305476

Please sign in to comment.