mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix a crash in adding a contact.
This commit is contained in:
parent
03e60ed329
commit
77330aa6a7
1 changed files with 11 additions and 5 deletions
|
@ -365,6 +365,8 @@ void AddContactBox::save() {
|
||||||
firstName = lastName;
|
firstName = lastName;
|
||||||
lastName = QString();
|
lastName = QString();
|
||||||
}
|
}
|
||||||
|
const auto weak = Ui::MakeWeak(this);
|
||||||
|
const auto session = _session;
|
||||||
_sentName = firstName;
|
_sentName = firstName;
|
||||||
_contactId = base::RandomValue<uint64>();
|
_contactId = base::RandomValue<uint64>();
|
||||||
_addRequest = _session->api().request(MTPcontacts_ImportContacts(
|
_addRequest = _session->api().request(MTPcontacts_ImportContacts(
|
||||||
|
@ -375,18 +377,20 @@ 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, [=](
|
)).done(crl::guard(weak, [=](
|
||||||
const MTPcontacts_ImportedContacts &result) {
|
const MTPcontacts_ImportedContacts &result) {
|
||||||
const auto &data = result.match([](
|
const auto &data = result.match([](
|
||||||
const auto &data) -> const MTPDcontacts_importedContacts& {
|
const auto &data) -> const MTPDcontacts_importedContacts& {
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
_session->data().processUsers(data.vusers());
|
session->data().processUsers(data.vusers());
|
||||||
|
if (!weak) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto extractUser = [&](const MTPImportedContact &data) {
|
const auto extractUser = [&](const MTPImportedContact &data) {
|
||||||
return data.match([&](const MTPDimportedContact &data) {
|
return data.match([&](const MTPDimportedContact &data) {
|
||||||
return (data.vclient_id().v == _contactId)
|
return (data.vclient_id().v == _contactId)
|
||||||
? _session->data().userLoaded(data.vuser_id())
|
? session->data().userLoaded(data.vuser_id())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -398,7 +402,9 @@ void AddContactBox::save() {
|
||||||
if (user->isContact() || user->session().supportMode()) {
|
if (user->isContact() || user->session().supportMode()) {
|
||||||
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
||||||
}
|
}
|
||||||
getDelegate()->hideLayer();
|
if (weak) { // showPeerHistory could close the box.
|
||||||
|
getDelegate()->hideLayer();
|
||||||
|
}
|
||||||
} else if (isBoxShown()) {
|
} else if (isBoxShown()) {
|
||||||
hideChildren();
|
hideChildren();
|
||||||
_retrying = true;
|
_retrying = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue