Send updateLanguagePackStrings when language pack is loaded for the first time.

This commit is contained in:
levlam 2023-03-22 21:40:05 +03:00
parent a9ba8f5a6c
commit de8b68a492
2 changed files with 8 additions and 7 deletions

View File

@ -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<chatTheme> = 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<languagePackString> = 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

View File

@ -1384,6 +1384,7 @@ void LanguagePackManager::on_get_language_pack_strings(
std::lock_guard<std::mutex> lock(language->mutex_);
int32 key_count_delta = 0;
if (language->version_ < version || !keys.empty()) {
auto is_first = language->version_ == -1;
vector<td_api::object_ptr<td_api::languagePackString>> 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<td_api::updateLanguagePackStrings>(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<td_api::updateLanguagePackStrings>(language_pack, language_code, std::move(strings)));
}
}
}
if (is_custom_language_code(language_code) && new_database_version == -1) {