Fix adding contacts.

Regression was introduced in 06982fdf04.
This commit is contained in:
John Preston 2019-07-30 13:48:48 +02:00
parent b05ea9fc25
commit e8a28a57df
2 changed files with 30 additions and 31 deletions

View File

@ -298,7 +298,9 @@ void AddContactBox::submit() {
} }
void AddContactBox::save() { void AddContactBox::save() {
if (_addRequest) return; if (_addRequest) {
return;
}
auto firstName = TextUtilities::PrepareForSending(_first->getLastText()); auto firstName = TextUtilities::PrepareForSending(_first->getLastText());
auto lastName = TextUtilities::PrepareForSending(_last->getLastText()); auto lastName = TextUtilities::PrepareForSending(_last->getLastText());
@ -331,37 +333,35 @@ void AddContactBox::save() {
MTP_string(phone), MTP_string(phone),
MTP_string(firstName), MTP_string(firstName),
MTP_string(lastName))) MTP_string(lastName)))
)).done(crl::guard(this, [=](const MTPcontacts_ImportedContacts &res) { )).done(crl::guard(this, [=](
})).send(); const MTPcontacts_ImportedContacts &result) {
} result.match([&](const MTPDcontacts_importedContacts &data) {
_session->data().processUsers(data.vusers());
void AddContactBox::importDone(const MTPcontacts_ImportedContacts &result) { const auto extractUser = [&](const MTPImportedContact &data) {
if (!isBoxShown() || !App::main()) return; return data.match([&](const MTPDimportedContact &data) {
return (data.vclient_id().v == _contactId)
const auto &d = result.c_contacts_importedContacts(); ? _session->data().userLoaded(data.vuser_id().v)
_session->data().processUsers(d.vusers()); : nullptr;
});
const auto &v = d.vimported().v; };
const auto user = [&]() -> UserData* { const auto &list = data.vimported().v;
if (!v.isEmpty()) { const auto user = list.isEmpty()
auto &c = v.front().c_importedContact(); ? nullptr
if (c.vclient_id().v == _contactId) { : extractUser(list.front());
return _session->data().userLoaded(c.vuser_id().v); if (user) {
if (user->isContact() || user->session().supportMode()) {
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
}
Ui::hideLayer();
} else if (isBoxShown()) {
hideChildren();
_retrying = true;
updateButtons();
update();
} }
} });
return nullptr; })).send();
}();
if (user) {
if (user->isContact() || user->session().supportMode()) {
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
}
Ui::hideLayer();
} else {
hideChildren();
_retrying = true;
updateButtons();
update();
}
} }
void AddContactBox::retry() { void AddContactBox::retry() {

View File

@ -75,7 +75,6 @@ private:
void retry(); void retry();
void save(); void save();
void updateButtons(); void updateButtons();
void importDone(const MTPcontacts_ImportedContacts &result);
const not_null<Main::Session*> _session; const not_null<Main::Session*> _session;