mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Slightly refactored AddContactBox.
This commit is contained in:
parent
7ad08b3ef8
commit
dd92f7fb9d
1 changed files with 27 additions and 25 deletions
|
@ -418,32 +418,34 @@ void AddContactBox::save() {
|
||||||
MTP_string(lastName)))
|
MTP_string(lastName)))
|
||||||
)).done(crl::guard(this, [=](
|
)).done(crl::guard(this, [=](
|
||||||
const MTPcontacts_ImportedContacts &result) {
|
const MTPcontacts_ImportedContacts &result) {
|
||||||
result.match([&](const MTPDcontacts_importedContacts &data) {
|
const auto &data = result.match([](
|
||||||
_session->data().processUsers(data.vusers());
|
const auto &data) -> const MTPDcontacts_importedContacts& {
|
||||||
|
return data;
|
||||||
const auto extractUser = [&](const MTPImportedContact &data) {
|
|
||||||
return data.match([&](const MTPDimportedContact &data) {
|
|
||||||
return (data.vclient_id().v == _contactId)
|
|
||||||
? _session->data().userLoaded(data.vuser_id())
|
|
||||||
: nullptr;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const auto &list = data.vimported().v;
|
|
||||||
const auto user = list.isEmpty()
|
|
||||||
? nullptr
|
|
||||||
: extractUser(list.front());
|
|
||||||
if (user) {
|
|
||||||
if (user->isContact() || user->session().supportMode()) {
|
|
||||||
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
|
||||||
}
|
|
||||||
Ui::hideLayer();
|
|
||||||
} else if (isBoxShown()) {
|
|
||||||
hideChildren();
|
|
||||||
_retrying = true;
|
|
||||||
updateButtons();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
_session->data().processUsers(data.vusers());
|
||||||
|
|
||||||
|
const auto extractUser = [&](const MTPImportedContact &data) {
|
||||||
|
return data.match([&](const MTPDimportedContact &data) {
|
||||||
|
return (data.vclient_id().v == _contactId)
|
||||||
|
? _session->data().userLoaded(data.vuser_id())
|
||||||
|
: nullptr;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const auto &list = data.vimported().v;
|
||||||
|
const auto user = list.isEmpty()
|
||||||
|
? nullptr
|
||||||
|
: extractUser(list.front());
|
||||||
|
if (user) {
|
||||||
|
if (user->isContact() || user->session().supportMode()) {
|
||||||
|
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
||||||
|
}
|
||||||
|
Ui::hideLayer();
|
||||||
|
} else if (isBoxShown()) {
|
||||||
|
hideChildren();
|
||||||
|
_retrying = true;
|
||||||
|
updateButtons();
|
||||||
|
update();
|
||||||
|
}
|
||||||
})).send();
|
})).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue