Version 1.7.10: Add share phone confirmation.

This commit is contained in:
John Preston 2019-06-24 14:49:53 +02:00
parent 022fb0c81b
commit 764490b4a9
2 changed files with 29 additions and 8 deletions

View File

@ -1213,6 +1213,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_new_contact_block_done" = "{user} is now blocked.";
"lng_new_contact_add" = "Add contact";
"lng_new_contact_share" = "Share my phone number";
"lng_new_contact_share_sure" = "Are you sure you want to share your phone number {phone} with {user}?";
"lng_new_contact_share_done" = "{user} can now see your phone number.";
"lng_new_contact_add_name" = "Add {user} to contacts";
"lng_new_contact_add_done" = "{user} is now in your contact list.";

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h"
#include "ui/widgets/labels.h"
#include "ui/toast/toast.h"
#include "ui/text/text_utilities.h"
#include "data/data_peer.h"
#include "data/data_user.h"
#include "data/data_chat.h"
@ -310,15 +311,34 @@ void ContactStatus::setupBlockHandler(not_null<UserData*> user) {
void ContactStatus::setupShareHandler(not_null<UserData*> user) {
_bar.entity()->shareClicks(
) | rpl::start_with_next([=] {
user->setSettings(0);
user->session().api().request(MTPcontacts_AcceptContact(
user->inputUser
)).done([=](const MTPUpdates &result) {
user->session().api().applyUpdates(result);
const auto box = std::make_shared<QPointer<BoxContent>>();
const auto share = [=] {
user->setSettings(0);
user->session().api().request(MTPcontacts_AcceptContact(
user->inputUser
)).done([=](const MTPUpdates &result) {
user->session().api().applyUpdates(result);
Ui::Toast::Show(
tr::lng_new_contact_share_done(tr::now, lt_user, user->shortName()));
}).send();
Ui::Toast::Show(tr::lng_new_contact_share_done(
tr::now,
lt_user,
user->shortName()));
}).send();
if (*box) {
(*box)->closeBox();
}
};
*box = _window->show(Box<ConfirmBox>(
tr::lng_new_contact_share_sure(
tr::now,
lt_phone,
Ui::Text::WithEntities(
App::formatPhone(user->session().user()->phone())),
lt_user,
Ui::Text::Bold(App::peerName(user)),
Ui::Text::WithEntities),
tr::lng_box_ok(tr::now),
share));
}, _bar.lifetime());
}