From de8b68a492d34632e2d550cc529e46e77ee9d919 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 22 Mar 2023 21:40:05 +0300 Subject: [PATCH] Send updateLanguagePackStrings when language pack is loaded for the first time. --- td/generate/scheme/td_api.tl | 2 +- td/telegram/LanguagePackManager.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d976c7cd2..cf73ab456 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5530,7 +5530,7 @@ updateSelectedBackground for_dark_theme:Bool background:background = Update; //@description The list of available chat themes has changed @chat_themes The new list of chat themes updateChatThemes chat_themes:vector = Update; -//@description Some language pack strings have been updated @localization_target Localization target to which the language pack belongs @language_pack_id Identifier of the updated language pack @strings List of changed language pack strings +//@description Some language pack strings have been updated @localization_target Localization target to which the language pack belongs @language_pack_id Identifier of the updated language pack @strings List of changed language pack strings; empty if all strings have changed updateLanguagePackStrings localization_target:string language_pack_id:string strings:vector = Update; //@description The connection state has changed. This update must be used only to show a human-readable description of the connection state @state The new connection state diff --git a/td/telegram/LanguagePackManager.cpp b/td/telegram/LanguagePackManager.cpp index 71e9a25ba..1761819f2 100644 --- a/td/telegram/LanguagePackManager.cpp +++ b/td/telegram/LanguagePackManager.cpp @@ -1384,6 +1384,7 @@ void LanguagePackManager::on_get_language_pack_strings( std::lock_guard lock(language->mutex_); int32 key_count_delta = 0; if (language->version_ < version || !keys.empty()) { + auto is_first = language->version_ == -1; vector> strings; if (language->version_ < version) { LOG(INFO) << "Set language pack " << language_code << " version to " << version; @@ -1482,18 +1483,18 @@ void LanguagePackManager::on_get_language_pack_strings( language->key_count_ = new_key_count; } - if (is_diff) { - send_closure( - G()->td(), &Td::send_update, - td_api::make_object(language_pack, language_code, std::move(strings))); - } - if (keys.empty() && !is_diff) { CHECK(new_database_version >= 0); language->is_full_ = true; language->deleted_strings_.clear(); } new_is_full = language->is_full_; + + if (is_diff || (new_is_full && is_first)) { + send_closure( + G()->td(), &Td::send_update, + td_api::make_object(language_pack, language_code, std::move(strings))); + } } } if (is_custom_language_code(language_code) && new_database_version == -1) {