Fix assertion violation when editing an admin.

There is a possibility that an EditAdminBox will be shown for someone
who can't add admins right now (in case server says he can edit one).

In that case assertion about the admins checkbox is false and we fix
that. Currently server sometimes does return this flag by mistake.
This commit is contained in:
John Preston 2017-07-02 22:23:41 +03:00
parent 305e15dd03
commit 96d1fe336a
1 changed files with 7 additions and 5 deletions

View File

@ -216,13 +216,15 @@ void EditAdminBox::prepare() {
addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins));
}
_aboutAddAdmins = addControl(object_ptr<Ui::FlatLabel>(this, st::boxLabel));
auto addAdmins = _checkboxes.find(Flag::f_add_admins);
t_assert(addAdmins != _checkboxes.end());
connect(addAdmins->second, &Ui::Checkbox::changed, this, [this] {
if (addAdmins != _checkboxes.end()) {
_aboutAddAdmins = addControl(object_ptr<Ui::FlatLabel>(this, st::boxLabel));
t_assert(addAdmins != _checkboxes.end());
connect(addAdmins->second, &Ui::Checkbox::changed, this, [this] {
refreshAboutAddAdminsText();
});
refreshAboutAddAdminsText();
});
refreshAboutAddAdminsText();
}
addButton(langFactory(lng_settings_save), [this] {
if (!_saveCallback) {