Wait for main menu bot icon to load.
This commit is contained in:
parent
597195a2e2
commit
4955cdcdce
|
@ -134,6 +134,9 @@ public:
|
||||||
[[nodiscard]] rpl::producer<> attachBotsUpdates() const {
|
[[nodiscard]] rpl::producer<> attachBotsUpdates() const {
|
||||||
return _attachBotsUpdates.events();
|
return _attachBotsUpdates.events();
|
||||||
}
|
}
|
||||||
|
void notifyBotIconLoaded() {
|
||||||
|
_attachBotsUpdates.fire({});
|
||||||
|
}
|
||||||
[[nodiscard]] bool disclaimerAccepted(
|
[[nodiscard]] bool disclaimerAccepted(
|
||||||
const AttachWebViewBot &bot) const;
|
const AttachWebViewBot &bot) const;
|
||||||
[[nodiscard]] bool showMainMenuNewBadge(
|
[[nodiscard]] bool showMainMenuNewBadge(
|
||||||
|
|
|
@ -59,6 +59,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
#include "mtproto/mtp_instance.h"
|
#include "mtproto/mtp_instance.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
|
#include "data/data_document_media.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -205,6 +206,9 @@ void SetupMenuBots(
|
||||||
const auto wrap = container->add(
|
const auto wrap = container->add(
|
||||||
object_ptr<Ui::VerticalLayout>(container));
|
object_ptr<Ui::VerticalLayout>(container));
|
||||||
const auto bots = &controller->session().attachWebView();
|
const auto bots = &controller->session().attachWebView();
|
||||||
|
const auto iconLoadLifetime = wrap->lifetime().make_state<
|
||||||
|
rpl::lifetime
|
||||||
|
>();
|
||||||
|
|
||||||
rpl::single(
|
rpl::single(
|
||||||
rpl::empty
|
rpl::empty
|
||||||
|
@ -214,7 +218,20 @@ void SetupMenuBots(
|
||||||
const auto width = container->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) {
|
const auto user = bot.user;
|
||||||
|
if (!bot.inMainMenu || !bot.media) {
|
||||||
|
continue;
|
||||||
|
} else if (const auto media = bot.media; !media->loaded()) {
|
||||||
|
if (!*iconLoadLifetime) {
|
||||||
|
auto &session = user->session();
|
||||||
|
*iconLoadLifetime = session.downloaderTaskFinished(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
if (media->loaded()) {
|
||||||
|
iconLoadLifetime->destroy();
|
||||||
|
bots->notifyBotIconLoaded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto button = Settings::AddButton(
|
const auto button = Settings::AddButton(
|
||||||
|
@ -233,7 +250,6 @@ void SetupMenuBots(
|
||||||
st::mainMenuButton.iconLeft,
|
st::mainMenuButton.iconLeft,
|
||||||
(height - icon->height()) / 2);
|
(height - icon->height()) / 2);
|
||||||
}, button->lifetime());
|
}, button->lifetime());
|
||||||
const auto user = bot.user;
|
|
||||||
const auto weak = Ui::MakeWeak(container);
|
const auto weak = Ui::MakeWeak(container);
|
||||||
button->setAcceptBoth(true);
|
button->setAcceptBoth(true);
|
||||||
button->clicks(
|
button->clicks(
|
||||||
|
|
Loading…
Reference in New Issue