Added initial click handler to boosts list in boosts info.
This commit is contained in:
parent
01573af0de
commit
e9a8acdc54
|
@ -9,7 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "api/api_premium.h"
|
||||
#include "api/api_statistics.h"
|
||||
#include "boxes/gift_premium_box.h"
|
||||
#include "boxes/peers/edit_peer_invite_link.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "info/boosts/create_giveaway_box.h"
|
||||
#include "info/boosts/info_boosts_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
|
@ -268,8 +272,20 @@ void InnerWidget::fill() {
|
|||
::Settings::AddSkip(inner);
|
||||
|
||||
if (status.firstSlice.total > 0) {
|
||||
auto boostClicked = [=](const Data::Boost &boost) {
|
||||
if (!boost.giftCodeLink.slug.isEmpty()) {
|
||||
ResolveGiftCode(_controller, boost.giftCodeLink.slug);
|
||||
} else if (boost.userId) {
|
||||
const auto user = _peer->owner().user(boost.userId);
|
||||
crl::on_main(this, [=] {
|
||||
_controller->showPeerInfo(user);
|
||||
});
|
||||
} else if (!boost.isUnclaimed) {
|
||||
_show->showToast(tr::lng_boosts_list_pending_about(tr::now));
|
||||
}
|
||||
};
|
||||
|
||||
::Settings::AddSkip(inner);
|
||||
using PeerPtr = not_null<PeerData*>;
|
||||
const auto header = inner->add(
|
||||
object_ptr<Statistic::Header>(inner),
|
||||
st::statisticsLayerMargins
|
||||
|
@ -283,7 +299,7 @@ void InnerWidget::fill() {
|
|||
Statistics::AddBoostsList(
|
||||
status.firstSlice,
|
||||
inner,
|
||||
[=](PeerPtr p) { _controller->showPeerInfo(p); },
|
||||
std::move(boostClicked),
|
||||
_peer,
|
||||
tr::lng_boosts_title());
|
||||
::Settings::AddSkip(inner);
|
||||
|
|
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Info::Statistics {
|
||||
namespace {
|
||||
|
||||
using BoostCallback = Fn<void(const Data::Boost &)>;
|
||||
constexpr auto kColorIndexUnclaimed = int(3);
|
||||
constexpr auto kColorIndexPending = int(4);
|
||||
|
||||
|
@ -104,7 +105,7 @@ struct MembersDescriptor final {
|
|||
|
||||
struct BoostsDescriptor final {
|
||||
Data::BoostsListSlice firstSlice;
|
||||
Fn<void(not_null<PeerData*>)> showPeerInfo;
|
||||
BoostCallback boostClickedCallback;
|
||||
not_null<PeerData*> peer;
|
||||
};
|
||||
|
||||
|
@ -501,7 +502,7 @@ private:
|
|||
void applySlice(const Data::BoostsListSlice &slice);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
Fn<void(not_null<PeerData*>)> _showPeerInfo;
|
||||
BoostCallback _boostClickedCallback;
|
||||
|
||||
Api::Boosts _api;
|
||||
Data::BoostsListSlice _firstSlice;
|
||||
|
@ -516,7 +517,7 @@ private:
|
|||
|
||||
BoostsController::BoostsController(BoostsDescriptor d)
|
||||
: _session(&d.peer->session())
|
||||
, _showPeerInfo(std::move(d.showPeerInfo))
|
||||
, _boostClickedCallback(std::move(d.boostClickedCallback))
|
||||
, _api(d.peer)
|
||||
, _firstSlice(std::move(d.firstSlice)) {
|
||||
PeerListController::setStyleOverrides(&st::boostsListBox);
|
||||
|
@ -566,11 +567,9 @@ void BoostsController::applySlice(const Data::BoostsListSlice &slice) {
|
|||
}
|
||||
|
||||
void BoostsController::rowClicked(not_null<PeerListRow*> row) {
|
||||
if (!row->special()) {
|
||||
crl::on_main([=, peer = row->peer()] {
|
||||
_showPeerInfo(peer);
|
||||
});
|
||||
return;
|
||||
if (_boostClickedCallback) {
|
||||
_boostClickedCallback(
|
||||
static_cast<const BoostRow*>(row.get())->boost());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,7 +676,7 @@ void AddMembersList(
|
|||
void AddBoostsList(
|
||||
const Data::BoostsListSlice &firstSlice,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
Fn<void(not_null<PeerData*>)> showPeerInfo,
|
||||
BoostCallback boostClickedCallback,
|
||||
not_null<PeerData*> peer,
|
||||
rpl::producer<QString> title) {
|
||||
const auto max = firstSlice.total;
|
||||
|
@ -688,7 +687,7 @@ void AddBoostsList(
|
|||
BoostsController controller;
|
||||
int limit = Api::Boosts::kFirstSlice;
|
||||
};
|
||||
auto d = BoostsDescriptor{ firstSlice, std::move(showPeerInfo), peer };
|
||||
auto d = BoostsDescriptor{ firstSlice, boostClickedCallback, peer };
|
||||
const auto state = container->lifetime().make_state<State>(std::move(d));
|
||||
|
||||
state->delegate.setContent(container->add(
|
||||
|
|
|
@ -14,6 +14,7 @@ class VerticalLayout;
|
|||
} // namespace Ui
|
||||
|
||||
namespace Data {
|
||||
struct Boost;
|
||||
struct BoostsListSlice;
|
||||
struct PublicForwardsSlice;
|
||||
struct SupergroupStatistics;
|
||||
|
@ -38,7 +39,7 @@ void AddMembersList(
|
|||
void AddBoostsList(
|
||||
const Data::BoostsListSlice &firstSlice,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
Fn<void(not_null<PeerData*>)> showPeerInfo,
|
||||
Fn<void(const Data::Boost &)> boostClickedCallback,
|
||||
not_null<PeerData*> peer,
|
||||
rpl::producer<QString> title);
|
||||
|
||||
|
|
Loading…
Reference in New Issue