MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / ShowShareGameBox

Function ShowShareGameBox

Telegram/SourceFiles/window/window_peer_menu.cpp:3589–3643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3587}
3588
3589base::weak_qptr<Ui::BoxContent> ShowShareGameBox(
3590 not_null<Window::SessionNavigation*> navigation,
3591 not_null<UserData*> bot,
3592 QString shortName) {
3593 const auto weak = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
3594 auto chosen = [=](not_null<Data::Thread*> thread) mutable {
3595 const auto confirm = std::make_shared<base::weak_qptr<Ui::BoxContent>>();
3596 auto send = crl::guard(thread, [=] {
3597 ShareBotGame(bot, thread, shortName);
3598 if (const auto strong = *weak) {
3599 strong->closeBox();
3600 }
3601 if (const auto strong = *confirm) {
3602 strong->closeBox();
3603 }
3604 navigation->showThread(
3605 thread,
3606 ShowAtUnreadMsgId,
3607 SectionShow::Way::ClearStack);
3608 });
3609 const auto confirmText = thread->peer()->isUser()
3610 ? tr::lng_bot_sure_share_game(
3611 tr::now,
3612 lt_user,
3613 thread->chatListName())
3614 : tr::lng_bot_sure_share_game_group(
3615 tr::now,
3616 lt_group,
3617 thread->chatListName());
3618 *confirm = navigation->parentController()->show(
3619 Ui::MakeConfirmBox({
3620 .text = confirmText,
3621 .confirmed = std::move(send),
3622 }));
3623 };
3624 auto filter = [](not_null<Data::Thread*> thread) {
3625 return !thread->peer()->isSelf()
3626 && (Data::CanSend(thread, ChatRestriction::SendGames)
3627 || thread->asForum());
3628 };
3629 auto initBox = [](not_null<PeerListBox*> box) {
3630 box->addButton(tr::lng_cancel(), [box] {
3631 box->closeBox();
3632 });
3633 };
3634 *weak = navigation->parentController()->show(Box<PeerListBox>(
3635 std::make_unique<ChooseRecipientBoxController>(ChooseRecipientArgs{
3636 .session = &navigation->session(),
3637 .callback = std::move(chosen),
3638 .filter = std::move(filter),
3639 .moneyRestrictionError = WriteMoneyRestrictionError,
3640 }),
3641 std::move(initBox)));
3642 return weak->get();
3643}
3644
3645base::weak_qptr<Ui::BoxContent> ShowDropMediaBox(
3646 not_null<Window::SessionNavigation*> navigation,

Callers 1

Calls 13

ShareBotGameFunction · 0.85
CanSendFunction · 0.85
showThreadMethod · 0.80
isSelfMethod · 0.80
asForumMethod · 0.80
MakeConfirmBoxFunction · 0.50
isUserMethod · 0.45
peerMethod · 0.45
showMethod · 0.45
parentControllerMethod · 0.45
addButtonMethod · 0.45
sessionMethod · 0.45

Tested by

no test coverage detected