From dcb15d0a13ed59faa083a8f45ecf3ea97bb41707 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Jan 2020 19:25:36 +0300 Subject: [PATCH] Asynchronously reload emoji keywords languages after restart. GitOrigin-RevId: 1f24d44c715d96aead91402fdc7f6d7abf04d041 --- td/telegram/StickersManager.cpp | 14 ++++++++++---- td/telegram/StickersManager.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index ff3453de7..97ce9ac45 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -4948,8 +4948,8 @@ void StickersManager::on_get_language_codes(const string &key, Resulttd_db()->get_sqlite_pmc()->set(key, implode(language_codes, '$'), Auto()); auto it = emoji_language_codes_.find(key); CHECK(it != emoji_language_codes_.end()); - it->second = std::move(language_codes); + if (it->second != language_codes) { + LOG(INFO) << "Update emoji language codes for " << key << " to " << language_codes; + G()->td_db()->get_sqlite_pmc()->set(key, implode(language_codes, '$'), Auto()); + it->second = std::move(language_codes); + } for (auto &promise : promises) { promise.set_value(Unit()); @@ -5007,6 +5010,9 @@ vector StickersManager::get_emoji_language_codes(const string &input_lan load_emoji_keywords_difference(language_code); } } + if (reloaded_emoji_keywords_.insert(key).second) { + load_language_codes(std::move(language_codes), std::move(key), Auto()); + } } return it->second; } diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 174510dc6..2e98fd230 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -613,6 +613,7 @@ class StickersManager : public Actor { std::unordered_map> emoji_language_codes_; std::unordered_map emoji_language_code_versions_; std::unordered_map emoji_language_code_last_difference_times_; + std::unordered_set reloaded_emoji_keywords_; std::unordered_map>> load_emoji_keywords_queries_; std::unordered_map>> load_language_codes_queries_; std::unordered_map emoji_suggestions_urls_;