Added filter for removed dictionaries when dictionary box is closed.

This commit is contained in:
23rd 2020-02-08 14:50:20 +03:00
parent 4bd34b35ae
commit e9e9ea2d69
1 changed files with 13 additions and 0 deletions

View File

@ -122,6 +122,7 @@ auto AddButtonWithLoader(
const Spellchecker::Dict &dict,
bool buttonEnabled) {
const auto id = dict.id;
buttonEnabled &= DictExists(id);
const auto button = content->add(
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
@ -272,6 +273,11 @@ void ManageDictionariesBox::prepare() {
this,
_session->settings().dictionariesEnabled()));
// The initial list of enabled rows may differ from the list of languages
// in settings, so we should store it when box opens
// and save it when box closes (don't do it when "Save" was pressed).
const auto initialEnabledRows = inner->enabledRows();
setTitle(tr::lng_settings_manage_dictionaries());
addButton(tr::lng_settings_save(), [=] {
@ -281,10 +287,17 @@ void ManageDictionariesBox::prepare() {
DictExists
) | ranges::to_vector);
_session->saveSettingsDelayed();
// Ignore boxClosing() when the Save button was pressed.
lifetime().destroy();
closeBox();
});
addButton(tr::lng_close(), [=] { closeBox(); });
boxClosing() | rpl::start_with_next([=] {
_session->settings().setDictionariesEnabled(initialEnabledRows);
_session->saveSettingsDelayed();
}, lifetime());
setDimensionsToContent(st::boxWidth, inner);
inner->heightValue(