mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Send paid shared contacts.
This commit is contained in:
parent
101d626d4f
commit
22b99b6d3e
1 changed files with 37 additions and 11 deletions
|
@ -1682,23 +1682,49 @@ void PeerMenuShareContactBox(
|
||||||
auto recipient = peer->isUser()
|
auto recipient = peer->isUser()
|
||||||
? title
|
? title
|
||||||
: ('\xAB' + title + '\xBB');
|
: ('\xAB' + title + '\xBB');
|
||||||
const auto weak = base::make_weak(thread);
|
struct State {
|
||||||
|
base::weak_ptr<Data::Thread> weak;
|
||||||
|
Fn<void(Api::SendOptions)> share;
|
||||||
|
SendPaymentHelper sendPayment;
|
||||||
|
};
|
||||||
|
const auto state = std::make_shared<State>();
|
||||||
|
state->weak = thread;
|
||||||
|
state->share = [=](Api::SendOptions options) {
|
||||||
|
const auto strong = state->weak.get();
|
||||||
|
if (!strong) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto withPaymentApproved = [=](int stars) {
|
||||||
|
auto copy = options;
|
||||||
|
copy.starsApproved = stars;
|
||||||
|
state->share(copy);
|
||||||
|
};
|
||||||
|
const auto checked = state->sendPayment.check(
|
||||||
|
navigation,
|
||||||
|
peer,
|
||||||
|
1,
|
||||||
|
options.starsApproved,
|
||||||
|
withPaymentApproved);
|
||||||
|
if (!checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigation->showThread(
|
||||||
|
strong,
|
||||||
|
ShowAtTheEndMsgId,
|
||||||
|
Window::SectionShow::Way::ClearStack);
|
||||||
|
auto action = Api::SendAction(strong, options);
|
||||||
|
action.clearDraft = false;
|
||||||
|
strong->session().api().shareContact(user, action);
|
||||||
|
};
|
||||||
|
|
||||||
navigation->parentController()->show(
|
navigation->parentController()->show(
|
||||||
Ui::MakeConfirmBox({
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_forward_share_contact(
|
.text = tr::lng_forward_share_contact(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_recipient,
|
lt_recipient,
|
||||||
recipient),
|
recipient),
|
||||||
.confirmed = [weak, user, navigation](Fn<void()> &&close) {
|
.confirmed = [state](Fn<void()> &&close) {
|
||||||
if (const auto strong = weak.get()) {
|
state->share({});
|
||||||
navigation->showThread(
|
|
||||||
strong,
|
|
||||||
ShowAtTheEndMsgId,
|
|
||||||
Window::SectionShow::Way::ClearStack);
|
|
||||||
auto action = Api::SendAction(strong);
|
|
||||||
action.clearDraft = false;
|
|
||||||
strong->session().api().shareContact(user, action);
|
|
||||||
}
|
|
||||||
close();
|
close();
|
||||||
},
|
},
|
||||||
.confirmText = tr::lng_forward_send(),
|
.confirmText = tr::lng_forward_send(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue