Allow messages when accepting miniapp terms.

This commit is contained in:
John Preston 2023-11-01 21:04:23 +04:00
parent 3da44eb5dd
commit 7d5d086ade

View file

@ -1537,8 +1537,10 @@ void AttachWebView::confirmAddToMenu(
} }
_confirmAddBox = active->show(Box([=](not_null<Ui::GenericBox*> box) { _confirmAddBox = active->show(Box([=](not_null<Ui::GenericBox*> box) {
const auto allowed = std::make_shared<Ui::Checkbox*>(); const auto allowed = std::make_shared<Ui::Checkbox*>();
const auto disclaimer = !disclaimerAccepted(bot);
const auto done = [=](Fn<void()> close) { const auto done = [=](Fn<void()> close) {
const auto state = ((*allowed) && (*allowed)->checked()) const auto state = (disclaimer
|| (*allowed) && (*allowed)->checked())
? ToggledState::AllowedToWrite ? ToggledState::AllowedToWrite
: ToggledState::Added; : ToggledState::Added;
toggleInMenu(bot.user, state, [=] { toggleInMenu(bot.user, state, [=] {
@ -1551,13 +1553,22 @@ void AttachWebView::confirmAddToMenu(
}); });
close(); close();
}; };
const auto disclaimer = !disclaimerAccepted(bot);
if (disclaimer) { if (disclaimer) {
FillDisclaimerBox(box, [=] { FillDisclaimerBox(box, [=] {
_disclaimerAccepted.emplace(bot.user); _disclaimerAccepted.emplace(bot.user);
_attachBotsUpdates.fire({}); _attachBotsUpdates.fire({});
done([] {}); 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 { } else {
Ui::ConfirmBox(box, { Ui::ConfirmBox(box, {
(bot.inMainMenu (bot.inMainMenu
@ -1569,40 +1580,26 @@ void AttachWebView::confirmAddToMenu(
Ui::Text::WithEntities), Ui::Text::WithEntities),
done, done,
}); });
} if (bot.requestWriteAccess) {
if (bot.requestWriteAccess) { (*allowed) = box->addRow(
(*allowed) = box->addRow( object_ptr<Ui::Checkbox>(
object_ptr<Ui::Checkbox>( box,
box, tr::lng_url_auth_allow_messages(
tr::lng_url_auth_allow_messages( tr::now,
tr::now, lt_bot,
lt_bot, Ui::Text::Bold(bot.name),
Ui::Text::Bold(bot.name), Ui::Text::WithEntities),
Ui::Text::WithEntities), true,
true, st::urlAuthCheckbox),
st::urlAuthCheckbox), style::margins(
style::margins( st::boxRowPadding.left(),
st::boxRowPadding.left(), (disclaimer
(disclaimer ? st::boxPhotoCaptionSkip
? st::boxPhotoCaptionSkip : st::boxRowPadding.left()),
: st::boxRowPadding.left()), st::boxRowPadding.right(),
st::boxRowPadding.right(), st::boxRowPadding.left()));
st::boxRowPadding.left())); (*allowed)->setAllowTextLines();
(*allowed)->setAllowTextLines();
}
if (disclaimer) {
if (!bot.requestWriteAccess) {
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));
} }
})); }));
} }