2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Added new setting for automatic dictionaries download.

This commit is contained in:
23rd
2020-02-20 22:27:21 +03:00
parent bb8aead078
commit bc6e1e7a0d
5 changed files with 54 additions and 16 deletions

View File

@@ -343,37 +343,39 @@ void Start(not_null<Main::Session*> session) {
{ &ph::lng_spellchecker_remove, tr::lng_spellchecker_remove() },
{ &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() },
} });
const auto settings = &session->settings();
if (!Platform::Spellchecker::IsSystemSpellchecker()) {
Spellchecker::SetWorkingDirPath(DictionariesPath());
session->settings().dictionariesEnabledChanges(
settings->dictionariesEnabledChanges(
) | rpl::start_with_next([](auto dictionaries) {
Platform::Spellchecker::UpdateLanguages(dictionaries);
}, session->lifetime());
session->settings().spellcheckerEnabledChanges(
settings->spellcheckerEnabledChanges(
) | rpl::start_with_next([=](auto enabled) {
Platform::Spellchecker::UpdateLanguages(
enabled
? session->settings().dictionariesEnabled()
? settings->dictionariesEnabled()
: std::vector<int>());
}, session->lifetime());
session->data().contactsLoaded().changes(
) | rpl::start_with_next([=](bool loaded) {
if (!loaded) {
return;
}
DownloadDictionaryInBackground(session, 0, DefaultLanguages());
}, session->lifetime());
if (settings->autoDownloadDictionaries()) {
session->data().contactsLoaded().changes(
) | rpl::start_with_next([=](bool loaded) {
if (!loaded) {
return;
}
DownloadDictionaryInBackground(session, 0, DefaultLanguages());
}, session->lifetime());
}
}
if (session->settings().spellcheckerEnabled()) {
if (settings->spellcheckerEnabled()) {
Platform::Spellchecker::UpdateLanguages(
session->settings().dictionariesEnabled());
settings->dictionariesEnabled());
}
}