Skip to content

Commit

Permalink
Allow messages when accepting miniapp terms.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 1, 2023
1 parent 3da44eb commit 7d5d086
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,8 +1537,10 @@ void AttachWebView::confirmAddToMenu(
}
_confirmAddBox = active->show(Box([=](not_null<Ui::GenericBox*> box) {
const auto allowed = std::make_shared<Ui::Checkbox*>();
const auto disclaimer = !disclaimerAccepted(bot);
const auto done = [=](Fn<void()> close) {
const auto state = ((*allowed) && (*allowed)->checked())
const auto state = (disclaimer
|| (*allowed) && (*allowed)->checked())
? ToggledState::AllowedToWrite
: ToggledState::Added;
toggleInMenu(bot.user, state, [=] {
Expand All @@ -1551,13 +1553,22 @@ void AttachWebView::confirmAddToMenu(
});
close();
};
const auto disclaimer = !disclaimerAccepted(bot);
if (disclaimer) {
FillDisclaimerBox(box, [=] {
_disclaimerAccepted.emplace(bot.user);
_attachBotsUpdates.fire({});
done([] {});
});
box->addRow(object_ptr<Ui::FixedHeightWidget>(
box,
st::boxRowPadding.left()));
box->addRow(object_ptr<Ui::FlatLabel>(
box,
tr::lng_bot_will_be_added(
lt_bot,
rpl::single(Ui::Text::Bold(bot.name)),
Ui::Text::WithEntities),
st::boxLabel));
} else {
Ui::ConfirmBox(box, {
(bot.inMainMenu
Expand All @@ -1569,40 +1580,26 @@ void AttachWebView::confirmAddToMenu(
Ui::Text::WithEntities),
done,
});
}
if (bot.requestWriteAccess) {
(*allowed) = box->addRow(
object_ptr<Ui::Checkbox>(
box,
tr::lng_url_auth_allow_messages(
tr::now,
lt_bot,
Ui::Text::Bold(bot.name),
Ui::Text::WithEntities),
true,
st::urlAuthCheckbox),
style::margins(
st::boxRowPadding.left(),
(disclaimer
? st::boxPhotoCaptionSkip
: st::boxRowPadding.left()),
st::boxRowPadding.right(),
st::boxRowPadding.left()));
(*allowed)->setAllowTextLines();
}
if (disclaimer) {
if (!bot.requestWriteAccess) {
box->addRow(object_ptr<Ui::FixedHeightWidget>(
box,
st::boxRowPadding.left()));
if (bot.requestWriteAccess) {
(*allowed) = box->addRow(
object_ptr<Ui::Checkbox>(
box,
tr::lng_url_auth_allow_messages(
tr::now,
lt_bot,
Ui::Text::Bold(bot.name),
Ui::Text::WithEntities),
true,
st::urlAuthCheckbox),
style::margins(
st::boxRowPadding.left(),
(disclaimer
? st::boxPhotoCaptionSkip
: st::boxRowPadding.left()),
st::boxRowPadding.right(),
st::boxRowPadding.left()));
(*allowed)->setAllowTextLines();
}
box->addRow(object_ptr<Ui::FlatLabel>(
box,
tr::lng_bot_will_be_added(
lt_bot,
rpl::single(Ui::Text::Bold(bot.name)),
Ui::Text::WithEntities),
st::boxLabel));
}
}));
}
Expand Down

0 comments on commit 7d5d086

Please sign in to comment.