Pass Ui::Show to all add participant handlers.

This commit is contained in:
John Preston 2024-04-01 17:54:44 +04:00
parent 5741bd9cca
commit 87acc921c3
18 changed files with 82 additions and 41 deletions

View file

@ -487,9 +487,9 @@ void ChatParticipants::requestCountDelayed(
} }
void ChatParticipants::add( void ChatParticipants::add(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
const std::vector<not_null<UserData*>> &users, const std::vector<not_null<UserData*>> &users,
std::shared_ptr<Ui::Show> show,
bool passGroupHistory, bool passGroupHistory,
Fn<void(bool)> done) { Fn<void(bool)> done) {
if (const auto chat = peer->asChat()) { if (const auto chat = peer->asChat()) {
@ -504,14 +504,14 @@ void ChatParticipants::add(
if (done) done(true); if (done) done(true);
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
const auto type = error.type(); const auto type = error.type();
ShowAddParticipantsError(type, peer, { 1, user }, show); ShowAddParticipantsError(show, type, peer, { 1, user });
if (done) done(false); if (done) done(false);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
} }
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
const auto hasBot = ranges::any_of(users, &UserData::isBot); const auto hasBot = ranges::any_of(users, &UserData::isBot);
if (!peer->isMegagroup() && hasBot) { if (!peer->isMegagroup() && hasBot) {
ShowAddParticipantsError("USER_BOT", peer, users, show); ShowAddParticipantsError(show, "USER_BOT", peer, users);
return; return;
} }
auto list = QVector<MTPInputUser>(); auto list = QVector<MTPInputUser>();
@ -531,7 +531,7 @@ void ChatParticipants::add(
channel, channel,
CollectForbiddenUsers(&channel->session(), result)); CollectForbiddenUsers(&channel->session(), result));
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), peer, users, show); ShowAddParticipantsError(show, error.type(), peer, users);
if (callback) callback(false); if (callback) callback(false);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
}; };

View file

@ -97,9 +97,9 @@ public:
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
const TLMembers &data); const TLMembers &data);
void add( void add(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
const std::vector<not_null<UserData*>> &users, const std::vector<not_null<UserData*>> &users,
std::shared_ptr<Ui::Show> show = nullptr,
bool passGroupHistory = true, bool passGroupHistory = true,
Fn<void(bool)> done = nullptr); Fn<void(bool)> done = nullptr);

View file

@ -3855,13 +3855,14 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
} }
void ApiWrap::sendBotStart( void ApiWrap::sendBotStart(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot, not_null<UserData*> bot,
PeerData *chat, PeerData *chat,
const QString &startTokenForChat) { const QString &startTokenForChat) {
Expects(bot->isBot()); Expects(bot->isBot());
if (chat && chat->isChannel() && !chat->isMegagroup()) { if (chat && chat->isChannel() && !chat->isMegagroup()) {
ShowAddParticipantsError("USER_BOT", chat, { 1, bot }); ShowAddParticipantsError(show, "USER_BOT", chat, { 1, bot });
return; return;
} }
@ -3893,7 +3894,7 @@ void ApiWrap::sendBotStart(
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
if (chat) { if (chat) {
const auto type = error.type(); const auto type = error.type();
ShowAddParticipantsError(type, chat, { 1, bot }); ShowAddParticipantsError(show, type, chat, { 1, bot });
} }
}).send(); }).send();
} }

View file

@ -53,6 +53,7 @@ class Key;
namespace Ui { namespace Ui {
struct PreparedList; struct PreparedList;
class Show;
} // namespace Ui } // namespace Ui
namespace Api { namespace Api {
@ -343,6 +344,7 @@ public:
BusinessShortcutId id); BusinessShortcutId id);
void sendMessage(MessageToSend &&message); void sendMessage(MessageToSend &&message);
void sendBotStart( void sendBotStart(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot, not_null<UserData*> bot,
PeerData *chat = nullptr, PeerData *chat = nullptr,
const QString &startTokenForChat = QString()); const QString &startTokenForChat = QString());

View file

@ -169,10 +169,10 @@ TextWithEntities PeerFloodErrorText(
} }
void ShowAddParticipantsError( void ShowAddParticipantsError(
std::shared_ptr<Ui::Show> show,
const QString &error, const QString &error,
not_null<PeerData*> chat, not_null<PeerData*> chat,
const std::vector<not_null<UserData*>> &users, const std::vector<not_null<UserData*>> &users) {
std::shared_ptr<Ui::Show> show) {
if (error == u"USER_BOT"_q) { if (error == u"USER_BOT"_q) {
const auto channel = chat->asChannel(); const auto channel = chat->asChannel();
if ((users.size() == 1) if ((users.size() == 1)
@ -189,6 +189,7 @@ void ShowAddParticipantsError(
} }
}; };
const auto saveCallback = SaveAdminCallback( const auto saveCallback = SaveAdminCallback(
show,
channel, channel,
user, user,
close, close,
@ -199,9 +200,10 @@ void ShowAddParticipantsError(
ChatAdminRightsInfo(), ChatAdminRightsInfo(),
QString()); QString());
box->setSaveCallback(saveCallback); box->setSaveCallback(saveCallback);
*weak = Ui::show(std::move(box)); *weak = box.data();
show->showBox(std::move(box));
}; };
Ui::show( show->showBox(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
.text = tr::lng_cant_invite_offer_admin(), .text = tr::lng_cant_invite_offer_admin(),
.confirmed = makeAdmin, .confirmed = makeAdmin,
@ -219,7 +221,7 @@ void ShowAddParticipantsError(
const auto text = PeerFloodErrorText(&chat->session(), type); const auto text = PeerFloodErrorText(&chat->session(), type);
Ui::show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther); Ui::show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther);
return; return;
} else if (error == u"USER_PRIVACY_RESTRICTED"_q && show) { } else if (error == u"USER_PRIVACY_RESTRICTED"_q) {
ChatInviteForbidden(show, chat, users); ChatInviteForbidden(show, chat, users);
return; return;
} }
@ -231,8 +233,6 @@ void ShowAddParticipantsError(
} else if (error == u"USER_KICKED"_q) { } else if (error == u"USER_KICKED"_q) {
// Trying to return a user who was kicked by admin. // Trying to return a user who was kicked by admin.
return tr::lng_cant_invite_banned(tr::now); return tr::lng_cant_invite_banned(tr::now);
} else if (error == u"USER_PRIVACY_RESTRICTED"_q) {
return tr::lng_cant_invite_privacy(tr::now);
} else if (error == u"USER_NOT_MUTUAL_CONTACT"_q) { } else if (error == u"USER_NOT_MUTUAL_CONTACT"_q) {
// Trying to return user who does not have me in contacts. // Trying to return user who does not have me in contacts.
return tr::lng_failed_add_not_mutual(tr::now); return tr::lng_failed_add_not_mutual(tr::now);
@ -247,7 +247,7 @@ void ShowAddParticipantsError(
} }
return tr::lng_failed_add_participant(tr::now); return tr::lng_failed_add_participant(tr::now);
}(); }();
Ui::show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther); show->show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther);
} }
AddContactBox::AddContactBox( AddContactBox::AddContactBox(

View file

@ -34,6 +34,7 @@ template <typename Enum>
class Radioenum; class Radioenum;
class LinkButton; class LinkButton;
class UserpicButton; class UserpicButton;
class Show;
} // namespace Ui } // namespace Ui
enum class PeerFloodType { enum class PeerFloodType {
@ -46,10 +47,10 @@ enum class PeerFloodType {
not_null<Main::Session*> session, not_null<Main::Session*> session,
PeerFloodType type); PeerFloodType type);
void ShowAddParticipantsError( void ShowAddParticipantsError(
std::shared_ptr<Ui::Show> show,
const QString &error, const QString &error,
not_null<PeerData*> chat, not_null<PeerData*> chat,
const std::vector<not_null<UserData*>> &users, const std::vector<not_null<UserData*>> &users);
std::shared_ptr<Ui::Show> show = nullptr);
class AddContactBox : public Ui::BoxContent { class AddContactBox : public Ui::BoxContent {
public: public:

View file

@ -217,6 +217,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
? bot->botInfo->groupAdminRights ? bot->botInfo->groupAdminRights
: ChatAdminRights(); : ChatAdminRights();
const auto addingAdmin = requestedAddAdmin || (rights != 0); const auto addingAdmin = requestedAddAdmin || (rights != 0);
const auto show = controller->uiShow();
if (addingAdmin) { if (addingAdmin) {
const auto scope = _scope; const auto scope = _scope;
const auto token = _token; const auto token = _token;
@ -224,11 +225,12 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
ChatAdminRightsInfo newRights, ChatAdminRightsInfo newRights,
const QString &rank) { const QString &rank) {
if (scope == Scope::GroupAdmin) { if (scope == Scope::GroupAdmin) {
chat->session().api().sendBotStart(bot, chat, token); chat->session().api().sendBotStart(show, bot, chat, token);
} }
close(); close();
}; };
const auto saveCallback = SaveAdminCallback( const auto saveCallback = SaveAdminCallback(
show,
chat, chat,
bot, bot,
done, done,
@ -245,7 +247,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
controller->show(std::move(box)); controller->show(std::move(box));
} else { } else {
auto callback = crl::guard(this, [=] { auto callback = crl::guard(this, [=] {
AddBotToGroup(bot, chat, _token); AddBotToGroup(show, bot, chat, _token);
controller->hideLayer(); controller->hideLayer();
}); });
controller->show(Ui::MakeConfirmBox({ controller->show(Ui::MakeConfirmBox({
@ -394,13 +396,14 @@ void AddBotToGroupBoxController::prepareViewHook() {
} }
void AddBotToGroup( void AddBotToGroup(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot, not_null<UserData*> bot,
not_null<PeerData*> chat, not_null<PeerData*> chat,
const QString &startToken) { const QString &startToken) {
if (!startToken.isEmpty()) { if (!startToken.isEmpty()) {
chat->session().api().sendBotStart(bot, chat, startToken); chat->session().api().sendBotStart(show, bot, chat, startToken);
} else { } else {
chat->session().api().chatParticipants().add(chat, { 1, bot }); chat->session().api().chatParticipants().add(show, chat, { 1, bot });
} }
if (const auto window = chat->session().tryResolveWindow()) { if (const auto window = chat->session().tryResolveWindow()) {
window->showPeerHistory(chat); window->showPeerHistory(chat);

View file

@ -76,6 +76,7 @@ private:
}; };
void AddBotToGroup( void AddBotToGroup(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot, not_null<UserData*> bot,
not_null<PeerData*> chat, not_null<PeerData*> chat,
const QString &startToken); const QString &startToken);

View file

@ -433,9 +433,9 @@ void AddParticipantsBoxController::inviteSelectedUsers(
const auto show = box->uiShow(); const auto show = box->uiShow();
const auto request = [=](bool checked) { const auto request = [=](bool checked) {
_peer->session().api().chatParticipants().add( _peer->session().api().chatParticipants().add(
show,
_peer, _peer,
users, users,
show,
checked); checked);
}; };
if (_peer->isChannel()) { if (_peer->isChannel()) {
@ -945,6 +945,7 @@ void AddSpecialBoxController::showAdmin(
user, user,
currentRights, currentRights,
_additional.adminRank(user)); _additional.adminRank(user));
const auto show = delegate()->peerListUiShow();
if (_additional.canAddOrEditAdmin(user)) { if (_additional.canAddOrEditAdmin(user)) {
const auto done = crl::guard(this, [=]( const auto done = crl::guard(this, [=](
ChatAdminRightsInfo newRights, ChatAdminRightsInfo newRights,
@ -956,7 +957,8 @@ void AddSpecialBoxController::showAdmin(
_editParticipantBox->closeBox(); _editParticipantBox->closeBox();
} }
}); });
box->setSaveCallback(SaveAdminCallback(_peer, user, done, fail)); box->setSaveCallback(
SaveAdminCallback(show, _peer, user, done, fail));
} }
_editParticipantBox = showBox(std::move(box)); _editParticipantBox = showBox(std::move(box));
} }

View file

@ -387,11 +387,12 @@ void EditAdminBox::prepare() {
_rank ? _rank->getLastText().trimmed() : QString()); _rank ? _rank->getLastText().trimmed() : QString());
}; };
_save = [=] { _save = [=] {
const auto show = uiShow();
if (!_saveCallback) { if (!_saveCallback) {
return; return;
} else if (_addAsAdmin && !_addAsAdmin->checked()) { } else if (_addAsAdmin && !_addAsAdmin->checked()) {
const auto weak = Ui::MakeWeak(this); const auto weak = Ui::MakeWeak(this);
AddBotToGroup(user(), peer(), _addingBot->token); AddBotToGroup(show, user(), peer(), _addingBot->token);
if (const auto strong = weak.data()) { if (const auto strong = weak.data()) {
strong->closeBox(); strong->closeBox();
} }

View file

@ -72,6 +72,7 @@ void RemoveAdmin(
} }
void AddChatParticipant( void AddChatParticipant(
std::shared_ptr<Ui::Show> show,
not_null<ChatData*> chat, not_null<ChatData*> chat,
not_null<UserData*> user, not_null<UserData*> user,
Fn<void()> onDone, Fn<void()> onDone,
@ -87,7 +88,7 @@ void AddChatParticipant(
onDone(); onDone();
} }
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), chat, { 1, user }); ShowAddParticipantsError(show, error.type(), chat, { 1, user });
if (onFail) { if (onFail) {
onFail(); onFail();
} }
@ -95,6 +96,7 @@ void AddChatParticipant(
} }
void SaveChatAdmin( void SaveChatAdmin(
std::shared_ptr<Ui::Show> show,
not_null<ChatData*> chat, not_null<ChatData*> chat,
not_null<UserData*> user, not_null<UserData*> user,
bool isAdmin, bool isAdmin,
@ -115,8 +117,15 @@ void SaveChatAdmin(
if (retryOnNotParticipant if (retryOnNotParticipant
&& isAdmin && isAdmin
&& (type == u"USER_NOT_PARTICIPANT"_q)) { && (type == u"USER_NOT_PARTICIPANT"_q)) {
AddChatParticipant(chat, user, [=] { AddChatParticipant(show, chat, user, [=] {
SaveChatAdmin(chat, user, isAdmin, onDone, onFail, false); SaveChatAdmin(
show,
chat,
user,
isAdmin,
onDone,
onFail,
false);
}, onFail); }, onFail);
} else if (onFail) { } else if (onFail) {
onFail(); onFail();
@ -125,6 +134,7 @@ void SaveChatAdmin(
} }
void SaveChannelAdmin( void SaveChannelAdmin(
std::shared_ptr<Ui::Show> show,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
ChatAdminRightsInfo oldRights, ChatAdminRightsInfo oldRights,
@ -145,7 +155,7 @@ void SaveChannelAdmin(
onDone(); onDone();
} }
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), channel, { 1, user }); ShowAddParticipantsError(show, error.type(), channel, { 1, user });
if (onFail) { if (onFail) {
onFail(); onFail();
} }
@ -206,6 +216,7 @@ Fn<void(
ChatAdminRightsInfo oldRights, ChatAdminRightsInfo oldRights,
ChatAdminRightsInfo newRights, ChatAdminRightsInfo newRights,
const QString &rank)> SaveAdminCallback( const QString &rank)> SaveAdminCallback(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<UserData*> user, not_null<UserData*> user,
Fn<void( Fn<void(
@ -219,6 +230,7 @@ Fn<void(
const auto done = [=] { if (onDone) onDone(newRights, rank); }; const auto done = [=] { if (onDone) onDone(newRights, rank); };
const auto saveForChannel = [=](not_null<ChannelData*> channel) { const auto saveForChannel = [=](not_null<ChannelData*> channel) {
SaveChannelAdmin( SaveChannelAdmin(
show,
channel, channel,
user, user,
oldRights, oldRights,
@ -229,7 +241,7 @@ Fn<void(
}; };
if (const auto chat = peer->asChatNotMigrated()) { if (const auto chat = peer->asChatNotMigrated()) {
const auto saveChatAdmin = [&](bool isAdmin) { const auto saveChatAdmin = [&](bool isAdmin) {
SaveChatAdmin(chat, user, isAdmin, done, onFail); SaveChatAdmin(show, chat, user, isAdmin, done, onFail);
}; };
if (newRights.flags == chat->defaultAdminRights(user).flags if (newRights.flags == chat->defaultAdminRights(user).flags
&& rank.isEmpty()) { && rank.isEmpty()) {
@ -1743,7 +1755,9 @@ void ParticipantsBoxController::showAdmin(not_null<UserData*> user) {
_editParticipantBox->closeBox(); _editParticipantBox->closeBox();
} }
}); });
box->setSaveCallback(SaveAdminCallback(_peer, user, done, fail)); const auto show = delegate()->peerListUiShow();
box->setSaveCallback(
SaveAdminCallback(show, _peer, user, done, fail));
} }
_editParticipantBox = showBox(std::move(box)); _editParticipantBox = showBox(std::move(box));
} }
@ -1863,7 +1877,8 @@ void ParticipantsBoxController::unkickParticipant(not_null<UserData*> user) {
delegate()->peerListRemoveRow(row); delegate()->peerListRemoveRow(row);
refreshRows(); refreshRows();
} }
_peer->session().api().chatParticipants().add(_peer, { 1, user }); const auto show = delegate()->peerListUiShow();
_peer->session().api().chatParticipants().add(show, _peer, { 1, user });
} }
void ParticipantsBoxController::kickParticipantSure( void ParticipantsBoxController::kickParticipantSure(
@ -1906,7 +1921,8 @@ void ParticipantsBoxController::removeAdminSure(not_null<UserData*> user) {
_editBox = nullptr; _editBox = nullptr;
if (const auto chat = _peer->asChat()) { if (const auto chat = _peer->asChat()) {
SaveChatAdmin(chat, user, false, crl::guard(this, [=] { const auto show = delegate()->peerListUiShow();
SaveChatAdmin(show, chat, user, false, crl::guard(this, [=] {
editAdminDone( editAdminDone(
user, user,
ChatAdminRightsInfo(), ChatAdminRightsInfo(),

View file

@ -17,6 +17,10 @@ class PeerListStories;
struct ChatAdminRightsInfo; struct ChatAdminRightsInfo;
struct ChatRestrictionsInfo; struct ChatRestrictionsInfo;
namespace Ui {
class Show;
} // namespace Ui
namespace Window { namespace Window {
class SessionNavigation; class SessionNavigation;
} // namespace Window } // namespace Window
@ -29,6 +33,7 @@ Fn<void(
ChatAdminRightsInfo oldRights, ChatAdminRightsInfo oldRights,
ChatAdminRightsInfo newRights, ChatAdminRightsInfo newRights,
const QString &rank)> SaveAdminCallback( const QString &rank)> SaveAdminCallback(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<UserData*> user, not_null<UserData*> user,
Fn<void( Fn<void(

View file

@ -1963,7 +1963,8 @@ void Controller::toggleBotManager(const QString &command) {
const auto botPeer = _peer->owner().peerLoaded( const auto botPeer = _peer->owner().peerLoaded(
peerFromMTP(result.data().vpeer())); peerFromMTP(result.data().vpeer()));
if (const auto bot = botPeer ? botPeer->asUser() : nullptr) { if (const auto bot = botPeer ? botPeer->asUser() : nullptr) {
_peer->session().api().sendBotStart(bot, bot, command); const auto show = controller->uiShow();
_peer->session().api().sendBotStart(show, bot, bot, command);
controller->showPeerHistory(bot); controller->showPeerHistory(bot);
} }
}).send(); }).send();

View file

@ -225,9 +225,9 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
const std::vector<not_null<UserData*>> &nonMembers, const std::vector<not_null<UserData*>> &nonMembers,
Fn<void()> finish) { Fn<void()> finish) {
peer->session().api().chatParticipants().add( peer->session().api().chatParticipants().add(
show,
peer, peer,
nonMembers, nonMembers,
show,
true, true,
[=](bool) { invite(users); finish(); }); [=](bool) { invite(users); finish(); });
}; };

View file

@ -4224,7 +4224,8 @@ SendMenu::Type HistoryWidget::sendButtonMenuType() const {
void HistoryWidget::unblockUser() { void HistoryWidget::unblockUser() {
if (const auto user = _peer ? _peer->asUser() : nullptr) { if (const auto user = _peer ? _peer->asUser() : nullptr) {
Window::PeerMenuUnblockUserWithBotRestart(user); const auto show = controller()->uiShow();
Window::PeerMenuUnblockUserWithBotRestart(show, user);
} else { } else {
updateControlsVisibility(); updateControlsVisibility();
} }
@ -4238,7 +4239,7 @@ void HistoryWidget::sendBotStartCommand() {
updateControlsVisibility(); updateControlsVisibility();
return; return;
} }
session().api().sendBotStart(_peer->asUser()); session().api().sendBotStart(controller()->uiShow(), _peer->asUser());
updateControlsVisibility(); updateControlsVisibility();
updateControlsGeometry(); updateControlsGeometry();
} }

View file

@ -1688,7 +1688,8 @@ void ActionsFiller::addBlockAction(not_null<UserData*> user) {
}); });
auto callback = [=] { auto callback = [=] {
if (user->isBlocked()) { if (user->isBlocked()) {
Window::PeerMenuUnblockUserWithBotRestart(user); const auto show = controller->uiShow();
Window::PeerMenuUnblockUserWithBotRestart(show, user);
if (user->isBot()) { if (user->isBot()) {
controller->showPeerHistory(user); controller->showPeerHistory(user);
} }

View file

@ -781,8 +781,9 @@ void Filler::addBlockUser() {
: tr::lng_profile_block_user(tr::now)); : tr::lng_profile_block_user(tr::now));
}; };
const auto blockAction = _addAction(blockText(user), [=] { const auto blockAction = _addAction(blockText(user), [=] {
const auto show = window->uiShow();
if (user->isBlocked()) { if (user->isBlocked()) {
PeerMenuUnblockUserWithBotRestart(user); PeerMenuUnblockUserWithBotRestart(show, user);
} else if (user->isBot()) { } else if (user->isBot()) {
user->session().api().blockedPeers().block(user); user->session().api().blockedPeers().block(user);
} else { } else {
@ -1700,10 +1701,12 @@ void PeerMenuBlockUserBox(
}); });
} }
void PeerMenuUnblockUserWithBotRestart(not_null<UserData*> user) { void PeerMenuUnblockUserWithBotRestart(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> user) {
user->session().api().blockedPeers().unblock(user, [=](bool success) { user->session().api().blockedPeers().unblock(user, [=](bool success) {
if (success && user->isBot() && !user->isSupport()) { if (success && user->isBot() && !user->isSupport()) {
user->session().api().sendBotStart(user); user->session().api().sendBotStart(show, user);
} }
}); });
} }

View file

@ -18,6 +18,7 @@ namespace Ui {
class RpWidget; class RpWidget;
class BoxContent; class BoxContent;
class GenericBox; class GenericBox;
class Show;
} // namespace Ui } // namespace Ui
namespace Data { namespace Data {
@ -109,7 +110,9 @@ void PeerMenuBlockUserBox(
not_null<PeerData*> peer, not_null<PeerData*> peer,
std::variant<v::null_t, bool> suggestReport, std::variant<v::null_t, bool> suggestReport,
std::variant<v::null_t, ClearChat, ClearReply> suggestClear); std::variant<v::null_t, ClearChat, ClearReply> suggestClear);
void PeerMenuUnblockUserWithBotRestart(not_null<UserData*> user); void PeerMenuUnblockUserWithBotRestart(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> user);
void BlockSenderFromRepliesBox( void BlockSenderFromRepliesBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,