Added initial boosts info to layer.

This commit is contained in:
23rd 2023-10-12 00:53:39 +03:00 committed by John Preston
parent 8b6d475882
commit f925a9e961
2 changed files with 35 additions and 0 deletions

View File

@ -7,6 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "info/boosts/info_boosts_inner_widget.h"
#include "api/api_statistics.h"
#include "ui/boxes/boost_box.h"
namespace Info::Boosts {
InnerWidget::InnerWidget(
@ -16,6 +19,37 @@ InnerWidget::InnerWidget(
: VerticalLayout(parent)
, _controller(controller)
, _peer(peer) {
const auto api = lifetime().make_state<Api::Boosts>(peer);
const auto fakeShowed = lifetime().make_state<rpl::event_stream<>>();
_showFinished.events(
) | rpl::take(1) | rpl::start_with_next([=] {
api->request(
) | rpl::start_with_error_done([](const QString &error) {
}, [=] {
const auto status = api->boostStatus();
Ui::FillBoostLimit(
fakeShowed->events(),
rpl::single(status.overview.isBoosted),
this,
Ui::BoostBoxData{
.boost = Ui::BoostCounters{
.level = status.overview.level,
.boosts = status.overview.boostCount,
.thisLevelBoosts
= status.overview.currentLevelBoostCount,
.nextLevelBoosts
= status.overview.nextLevelBoostCount,
.mine = status.overview.isBoosted,
}
});
resizeToWidth(width());
crl::on_main([=]{ fakeShowed->fire({}); });
}, lifetime());
}, lifetime());
}
rpl::producer<Ui::ScrollToRequest> InnerWidget::scrollToRequests() const {

View File

@ -931,6 +931,7 @@ void AddBubbleRow(
) | rpl::start_with_next([=](const QSize &parentSize, const QSize &size) {
container->resize(parentSize.width(), size.height());
}, bubble->lifetime());
bubble->show();
}
void AddLimitRow(