Close main menu on a web app opening.

This commit is contained in:
John Preston 2023-09-13 13:02:15 +04:00
parent 976c696004
commit e6a474d720

View File

@ -211,7 +211,7 @@ void SetupMenuBots(
) | rpl::then( ) | rpl::then(
bots->attachBotsUpdates() bots->attachBotsUpdates()
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
const auto width = wrap->widthNoMargins(); const auto width = container->widthNoMargins();
wrap->clear(); wrap->clear();
for (const auto &bot : bots->attachBots()) { for (const auto &bot : bots->attachBots()) {
if (!bot.inMainMenu) { if (!bot.inMainMenu) {
@ -234,6 +234,7 @@ void SetupMenuBots(
(height - icon->height()) / 2); (height - icon->height()) / 2);
}, button->lifetime()); }, button->lifetime());
const auto user = bot.user; const auto user = bot.user;
const auto weak = Ui::MakeWeak(container);
button->setAcceptBoth(true); button->setAcceptBoth(true);
button->clicks( button->clicks(
) | rpl::start_with_next([=](Qt::MouseButton which) { ) | rpl::start_with_next([=](Qt::MouseButton which) {
@ -241,6 +242,9 @@ void SetupMenuBots(
bots->requestSimple(controller, user, { bots->requestSimple(controller, user, {
.fromMainMenu = true, .fromMainMenu = true,
}); });
if (weak) {
controller->window().hideSettingsAndLayer();
}
} else { } else {
(*menu) = nullptr; (*menu) = nullptr;
(*menu) = base::make_unique_q<Ui::PopupMenu>( (*menu) = base::make_unique_q<Ui::PopupMenu>(